因此我收到了非常常见的ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) mysql错误.我已经尝试了论坛上的所有典型修复程序,通过mysql_safe方法登录,然后尝试重置我的root密码.但是这样做时,它会返回;
So im getting the very common ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) mysql error. I have tried all of the typical fixes on the forums, logging in via the mysql_safe method and then trying to reset my root password. However when doing so it returns with;
UPDATE user SET password=PASSWORD("PASSWORD")WHERE user="root"; Query OK, 0 rows affected (0.00 sec) Rows matched: 0 Changed: 0 Warnings: 0因此,因为没有行受到影响,所以我假设没有用户要实际更改.我试图创建一个用户:
So as no rows were affected I assumed there was no user to actually change. I tried to create a user:
CREATE USER 'root'@'localhost' IDENTIFIED BY 'root' -> GRANT ALL ON *.* TO 'root'@'localhost' -> flush privileges; However this returns with ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GRANT ALL ON *.* TO 'root'@'localhost'查看当前用户是什么:
mysql> SELECT user(); +--------+ | user() | +--------+ | root@ | +--------+我认为语法错误是"root"之后@之后没有任何内容的事实.我如何将这些信息编辑为root @ localhost并解决问题?
I assume the syntax error is the fact that nothing comes after the @ after "root". How can i edit this information to be root@localhost and correct the issue?
更新
在仔细阅读了mysqld文档之后,我进入了本节,它运行良好.
after carefully reading the mysqld docs i got to this section which worked perfectly.
停止mysqld并使用--skip-grant-tables选项重新启动它.这样一来,任何人都无需密码就可以使用所有特权进行连接.因为这是不安全的,所以您可能希望将--skip-grant-tables与--skip-networking结合使用,以防止远程客户端连接.
Stop mysqld and restart it with the --skip-grant-tables option. This enables anyone to connect without a password and with all privileges. Because this is insecure, you might want to use --skip-grant-tables in conjunction with --skip-networking to prevent remote clients from connecting.
使用以下命令连接到mysqld服务器:
Connect to the mysqld server with this command:
shell> mysql在mysql客户端中发出以下语句.将密码替换为您要使用的密码.
Issue the following statements in the mysql client. Replace the password with the password that you want to use.
mysql> UPDATE mysql.user SET Password=PASSWORD('MyNewPass') -> WHERE User='root'; mysql> FLUSH PRIVILEGES;FLUSH语句告诉服务器将授权表重新加载到内存中,以便它注意到密码更改.
The FLUSH statement tells the server to reload the grant tables into memory so that it notices the password change.
推荐答案它应该是三个sql语句,
it should be three sql statements,
CREATE USER 'root'@'localhost' IDENTIFIED BY PASSWORD 'root'; GRANT ALL ON *.* TO 'root'@'localhost'; FLUSH PRIVILEGES;
- 创建用户
- CREATE USER
更多推荐
创建用户时更正mysql语法错误
发布评论