设置或修改mysql root密码:

update mysql.user set password=password('password') where user='root';
flush privileges;

删除默认的演示数据库和用户:

drop database test; //删除test表
use mysql;
delete from db;
delete from user where not(host="localhost" and user="root"); //删除除root外的其他用户
flush privileges;

更改默认root账号名称:

update mysql.user set user="admin" where user="root";
flush privileges;

本地文件安全、禁止远程连接mysql、限制普通用户浏览其它数据库

远程管理可通过phpmyadmin,编辑my.cnf在[mysqld]添加:

set-variable=local-infile=0
skip-networking
--skip-show-database

最小权限用户:

grant select,insert,update,delete,create,drop privileges on database.* to user@localhost identified by 'passwd';

快速检查并修复MySQL数据库

$ mysqlcheck -A -o -r -p
$ mysqlcheck -o -r database -p

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

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

已赞 1 0 评论