- 查看初始密码
初始密码存放在/etc/mysql/debian.cnf文件中
/etc/mysql$ sudo cat debian.cnf
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = debian-sys-maint
password = OSozOdppag50NmbG
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = OSozOdppag50NmbG
socket = /var/run/mysqld/mysqld.sock
/etc/mysql$ mysql -u debian-sys-maint -p
Enter password: OSozOdppag50NmbG
- 修改密码
注意:老的语句已经不行了 update user set authentication_string=password(“newPassword”) where user=“root”;
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';// 123456为新密码
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> quit;
Bye
mysql -uroot -p