1 查看Linux发行版本
[root@typecodes ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
2 安装MySQL的Yum Repository
文档详见 A Quick Guide to Using the MySQL Yum Repository
3 启动数据库
[root@typecodes ~]# systemctl start mysqld.service
4 获取初始密码
使用YUM安装并启动MySQL服务后,MySQL进程会自动在进程日志中打印root用户的初始密码:
grep "password" /var/log/mysqld.log
5 修改root用户密码
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
Tips:解决 MySQL 5.7 中 Your password does not satisfy the current policy requirements. 问题
6 创建用户并为用户设置权限
CREATE USER 'dev' @'%' INDENTIFIED BY 'password';
grant all *.* to 'dev'@'%' INDENTIFIED BY 'password';
FLUSH PRIVILEGES;