5.重置mysql密码
关闭mysql服务
systemctl stop mysql.service 绕过密码验证
mysqld_safe --user=mysql --skip-grant-tables--skip-networking
#提示一下内容后
161212 15:10:30 mysqld_safe Logging to '/var/lib/mysql/localhost.localdomain.err'.
161212 15:10:30 mysqld_safe A mysqld process already exists
按Ctrl+c终止 输入用户登录命令
mysql -u root mysql
UPDATE user SET Password=PASSWORD('your_password') where USER='root';
#将your_password改为自己的密码
FLUSH PRIVILEGES;#更新
quit#退出mysql
systemctl start mysql.service#启动mysql 这是数据库依旧不能使用,登录会提示
You must SET PASSWORD before executing this statement 解决办法
mysql -u root -p your_password
SET PASSWORD = PASSWORD('your_new_password'); 至此,mysql安装成功.