mysql - 某些新安装的版本设置初始化密码
访问量: 1137
1. 使用secure install , 我的不行
2. 用这个方法: 参考 https://askubuntu.com/a/1110137/52678
mysql> show databases;
mysql> use mysql;
mysql> update user set authentication_string=PASSWORD("new_password") where user='root'; ( 8.0 的mysql会报错)
或者
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'my_new_pass'; (8.0 下可用)
mysql> update user set plugin="mysql_native_password";
mysql> flush privileges;
mysql> quit;
或者使用这个方法:(参考: https://stackoverflow.com/a/52674808/445908)
sudo mysql -u root
Then create a normal user, set a password, then use that user to work.
create user 'user'@'localhost' identified by 'user1234';
grant all on your_database.* to 'user'@'localhost';
select host, user from mysql.user;
Then try to access:
mysql -u user -puser1234