- 首先登陆mysql
mysql -u root -p
- 初始化密码位置
vi /var/log/mysqld.log
2018-05-10T06:27:45.658106Z 1 [Note] A temporary password is generated for root@localhost: an_F13N:fXNf
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');
Query OK, 0 rows affected, 1 warning (0.00 sec)