mysql 设置无密码登陆

登入 MySQL 报错:

C:Usersdell>mysql -uroot -p
Enter password: ****
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

尝试修改 root 用户密码:

打开 my.ini,找到 [mysqld],在下面添加:

skip-grant-tables

此时使用 root 账号,密码处按回车即可登录。

修改密码:

mysql>update mysql.user set authentication_string=password('new_password') where user='root' and Host ='localhost'
mysql> ALTER USER USER() IDENTIFIED BY 'news_password';

刷新权限:

FLUSH PRIVILEGES;

注释掉 my.ini 中刚才添加的

skip-grant-tables

重新登录。

此时查看 mySQL 版本:

复制代码
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.7.17    |
+-----------+
复制代码
原文地址:https://www.cnblogs.com/passer00/p/6931487.html