MySQL:错误 1227 (42000):访问被拒绝 - 无法创建用户
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7797543/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MySQL: ERROR 1227 (42000): Access denied - Cannot CREATE USER
提问by cProg
I'm using MySQL 5.5.16 noinstall Zip Archive on Win7.
我在 Win7 上使用 MySQL 5.5.16 noinstall Zip Archive。
After I started the server, the command show databases
showed me a list of 2 databases: information_schema
and test
. The latter is empty.
启动服务器后,该命令show databases
向我显示了 2 个数据库的列表:information_schema
和test
. 后者是空的。
Where is the table user
?
桌子在哪里user
?
I tried to create a new user through this command create user newUser;
and got the following error message: ERROR 1227 (42000): Access denied; you need (at least one of) the CREATE USER privilege(s) for this operation
我尝试通过此命令创建一个新用户create user newUser;
并收到以下错误消息:ERROR 1227 (42000): Access denied; you need (at least one of) the CREATE USER privilege(s) for this operation
What should I do to create, databases, tables, and do all the operations I want to do? I don't know if the fact that I'm using MySQL 5.5.16 noinstall Zip Archive
has something to do with the error message?
我应该做什么来创建、数据库、表,并执行我想做的所有操作?我不知道我使用的事实MySQL 5.5.16 noinstall Zip Archive
是否与错误消息有关?
回答by RolandoMySQLDBA
First thing to do is run this:
首先要做的是运行这个:
SHOW GRANTS;
You will quickly see you were assigned the anonymous user to authenticate into mysql.
您将很快看到您被分配了匿名用户以对 mysql 进行身份验证。
Instead of logging into mysql with
而不是登录到mysql
mysql
login like this:
像这样登录:
mysql -uroot
By default, root@localhost has all rights and no password.
默认情况下,root@localhost 拥有所有权限且没有密码。
If you cannot login as root without a password, do the following:
如果您在没有密码的情况下无法以 root 身份登录,请执行以下操作:
Step 01) Add the two options in the mysqld section of my.ini:
步骤01)在my.ini的mysqld部分添加两个选项:
[mysqld]
skip-grant-tables
skip-networking
Step 02) Restart mysql
步骤 02) 重启 mysql
net stop mysql
<wait 10 seconds>
net start mysql
Step 03) Connect to mysql
步骤 03) 连接到 mysql
mysql
Step 04) Create a password from root@localhost
步骤 04) 从 root@localhost 创建密码
UPDATE mysql.user SET password=password('whateverpasswordyoulike')
WHERE user='root' AND host='localhost';
exit
Step 05) Restart mysql
步骤 05) 重启 mysql
net stop mysql
<wait 10 seconds>
net start mysql
Step 06) Login as root with password
步骤 06) 以 root 用户身份登录并使用密码
mysql -u root -p
You should be good from there.
从那里你应该很好。
CAVEAT: Please remove anonymous users !!!
警告:请删除匿名用户!!!