yum install mysql-server
mysql_secure_installation

vi /etc/mysql/my.cnf
#不让外部IP访问mysql
bind-address = 127.0.0.1
#服务器端禁用所有LOAD DATA LOCAL命令
local-infile=0
#添加额外的log日志记录信息
log=/var/log/mylog

更改root用户名
rename user ‘root’@’localhost’ to ‘newAdmin’@’localhost’;

查看用户信息
select user,host,password from mysql.user;

在退出之前执行以下命令
FLUSH PRIVILEGES;

每个应用建立各自的MySQL用户,用户只具有所需的最小权限
create database newDb;
CREATE USER ‘newuser’@’localhost’ IDENTIFIED BY ‘password’;
GRANT SELECT,UPDATE,DELETE ON newDb.* TO ‘newuser’@’localhost’;
FLUSH PRIVILEGES;

移除某用户权限
REVOKE UPDATE ON newDb.* FROM ‘newuser’@’localhost’;

赋予用户所有权限
GRANT ALL ON newDb.* TO ‘newuser’@’localhost’;