Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[教程] Mysql基本安全设置,高手就跳过吧!

[复制链接]
teway 发表于 2013-10-4 11:15:40 | 显示全部楼层 |阅读模式
本帖最后由 teway 于 2013-10-4 11:17 编辑

1.设置或修改Mysql root密码:
默认安装后空密码,以mysqladmin命令设置密码:
  1. mysqladmin -uroot password "password"
复制代码

Mysql命令设置密码:

  1. set password for root@localhost=password('password);
复制代码

更改密码:

  1. update mysql.user set password=password('password') where user='root';
  2. flush privileges;
复制代码

2.删除默认的数据库和用户

  1. drop database test;
  2. use mysql;
  3. delete from db;
  4. delete from user where not(host="localhost" and user="root");
  5. flush privileges;
复制代码

3. 更改默认root账号名称:

  1. update mysql.user set user="admin" where user="root";
  2. flush privileges;
复制代码

4. 本地文件安全:

  1. set-variable=local-infile=0
复制代码

5. 禁止远程连接mysql,远程管理可通过phpmyadmin,编辑my.cnf在[mysqld]添加:

  1. skip-networking
复制代码

6.最小权限用户:

  1. create database db1;
  2. grant select,insert,update,delete,create,drop privileges on database.* to user@localhost identified by 'passwd';
复制代码

7. 限制普通用户浏览其它数据库,编辑my.cnf在[mysqld]添加:

  1. --skip-show-database
复制代码

8.快速修复MySQL数据库
修复数据库

  1. mysqlcheck -A -o -r -p
复制代码

修复指定的数据库

  1. mysqlcheck  -o -r database -p
复制代码

9.跟据内存的大小选择MySQL的配置文件:

  1. my-small.cnf # > my-medium.cnf # 32M - 64M
  2. my-large.cnf # memory = 512M
  3. my-huge.cnf # 1G-2G
  4. my-innodb-heavy-4G.cnf # 4GB
复制代码

azt_008 发表于 2013-10-16 19:33:51 | 显示全部楼层
好帖 菜鸟收藏
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-5-3 16:52 , Processed in 0.139292 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表