shell> yum install mysql-community-server
# 完成后启动服务
shell> service mysqld start
# 启动后,查看安装后自动生成的密码
shell> grep "password" /var/log/mysqld.log
## 输出
2015-12-24T02:12:21.721431Z 1 [Note] A temporary password is generated for root@localhost: s8)9B9)!#iWJ
2015-12-24T02:12:25.495271Z 0 [Note] Execution of init_file '/var/lib/mysql/install-validate-password-plugin.lv0PNr.sql' started.
2015-12-24T02:12:25.506256Z 0 [Note] Execution of init_file '/var/lib/mysql/install-validate-password-plugin.lv0PNr.sql' ended.
2015-12-24T02:12:27.323654Z 0 [Note] Shutting down plugin 'sha256_password'
2015-12-24T02:12:27.323657Z 0 [Note] Shutting down plugin 'mysql_native_password'
2015-12-24T02:12:29.351753Z 2 [Note] Access denied for user 'UNKNOWN_MYSQL_USER'@'localhost' (using password: NO)
## 第一行“root@localhost:”后面的字符就是密码了,我们需要用它来设置我们自己的root登录密码
shell> mysql_secure_installation
## 输出
Securing the MySQL server deployment.
Enter password for user root: [请在这里输出自动生成的密码,如:s8)9B9)!#iWJ]
## 注:密码必须满足1)长度大于8;2)包含至少1个数字,1个大写字母,1个小写字母,1个非字母数字的符号;3)长度不得超过32位。
## 完成后还需要设置一些初始化的配置,请按照提示来做
# 以上步骤结束后,可以使用root用户登录mysql试试了
shell> mysql -u root -p
# mysql的配置文件所在目录
shell> find / -name my.cnf
## 输出
/etc/my.cnf