安装mysql时,我没有在root密码字段中输入任何内容,但是当我运行mysql -u root
时,我仍然得到了Access denied for user 'root'@'localhost'
。无法将root密码设置为空
我以安全模式启动mysql,没有授权表,sudo mysql_safe --skip-grant-tables &
,然后跳入mysql -u root
没有问题。
然后我做了use mysql; update user set authentication_string=null where user='root';
和我:
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
任何人有原因的密码没有更新任何见解?
看看输出的最后几行。最后一行应该说'行匹配:1改变:1警告:0'。 'FLUSH PRIVILEGES;'这里什么都不做,因为没有任何变化。而且,在MySQL 5.7中'password'字段已被'authentication_string'替换。 –
是的,你是对的,我没有看到“0行受影响”。选择用户表并查看表中存在的根用户 –