一个新的mysql 5.7安装后我有root pw的问题。
我正在尝试用mysqld_safe --skip-grant-tables &
启动mysql并进入mysql mysql -u root
并尝试设置密码
root@localhost [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
root@localhost [(none)]> ALTER USER 'root@localhost' IDENTIFIED BY 'password';
我得到这个错误;
ERROR 1396 (HY000): Operation ALTER USER failed for 'root@localhost'@'%'
我也试过这种方式;
root@localhost [mysql]> update user set authentication_string=password('password') where user='root';
Query OK, 0 rows affected, 1 (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 1
两个都不工作请帮忙..
试试这个(用户和主机必须用''分隔):
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';
如果您使用DML更改权限:
update user set authentication_string=password('password') where user='root';
你必须运行:
FLUSH PRIVILEGES;