赞
踩
mysql8今年刚出,网上百度没有相关资料,我今天配置好了,就做个笔记:
打开shell窗口
cd/usr/local/mysql-…../bin
sudo ./mysqld_safe –skip-grant-tables –skip-networking
重新打开一个shell窗口
mysql;
flush privileges;
ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘123456’;
flush privileges;
exit
现在已经把root密码设置为123456了,接着查看mysql相关进程
ps -ef|grep mysql
将mysql进程全部杀死(比如:kill 966;或者 sudo kill 966),正常开启mysql
以上操作,写的比较简单,一步一步做,如果出现其他问题及时解决。
附上官网详细解说:http://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html
Resetting the Root Password: Generic Instructions
The preceding sections provide password-resetting instructions specifically for Windows and Unix and Unix-like systems. Alternatively, on any platform, you can reset the password using the mysql client (but this approach is less secure):
Stop the MySQL server if necessary, then restart it with the –skip-grant-tables option. This enables anyone to connect without a password and with all privileges, and disables account-management statements such as ALTER USER and SET PASSWORD. Because this is insecure, you might want to use –skip-grant-tables in conjunction with –skip-networking to prevent remote clients from connecting.
Connect to the MySQL server using the mysql client; no password is necessary because the server was started with –skip-grant-tables:
shell> mysql
In the mysql client, tell the server to reload the grant tables so that account-management statements work:
mysql> FLUSH PRIVILEGES;
Then change the ‘root’@’localhost’ account password. Replace the password with the password that you want to use. To change the password for a root account with a different host name part, modify the instructions to use that host name.
mysql> ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘MyNewPass’;
You should now be able to connect to the MySQL server as root using the new password. Stop the server and restart it normally (without the –skip-grant-tables and –skip-networking options).
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。