MySQL在Ubuntu上直接安装以后,直接通过mysql -u root登录,无需输入密码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
USE mysql; mysql> update user set host = '%' where host = 'localhost' and user = 'root'; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select user,host from user; +------------------+-----------+ | user | host | +------------------+-----------+ | root | % | | debian-sys-maint | localhost | | mysql.infoschema | localhost | | mysql.session | localhost | | mysql.sys | localhost | +------------------+-----------+ 5 rows in set (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'xxxxxxx'; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) |
转载时请保留出处,违法转载追究到底:进城务工人员小梅 » MySQL 8.0正确修改root密码的方式