MySQL:错误1227(42000):访问被拒绝-无法创建用户 [英] MySQL: ERROR 1227 (42000): Access denied - Cannot CREATE USER
问题描述
我正在Win7上使用MySQL 5.5.16 noinstall Zip Archive.
I'm using MySQL 5.5.16 noinstall Zip Archive on Win7.
启动服务器后,命令show databases
向我显示了2个数据库的列表:information_schema
和test
.后者是空的.
After I started the server, the command show databases
showed me a list of 2 databases: information_schema
and test
. The latter is empty.
表user
在哪里?
我试图通过此命令create user newUser;
创建一个新用户,并收到以下错误消息:ERROR 1227 (42000): Access denied; you need (at least one of) the CREATE USER privilege(s) for this operation
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
我应该怎么做才能创建数据库,表以及要执行的所有操作?我不知道我正在使用MySQL 5.5.16 noinstall Zip Archive
的事实是否与错误消息有关?
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?
推荐答案
首先要做的是运行此命令:
First thing to do is run this:
SHOW GRANTS;
您将很快看到您被分配了匿名用户以对mysql进行身份验证.
You will quickly see you were assigned the anonymous user to authenticate into mysql.
代替使用
mysql
这样登录:
mysql -uroot
默认情况下,root @ localhost具有所有权限,并且没有密码.
By default, root@localhost has all rights and no password.
如果没有密码就无法以root用户身份登录,请执行以下操作:
If you cannot login as root without a password, do the following:
步骤01)在my.ini的mysqld部分中添加两个选项:
Step 01) Add the two options in the mysqld section of my.ini:
[mysqld]
skip-grant-tables
skip-networking
步骤02)重新启动mysql
Step 02) Restart mysql
net stop mysql
<wait 10 seconds>
net start mysql
步骤03)连接到mysql
Step 03) Connect to mysql
mysql
步骤04)从root @ localhost创建密码
Step 04) Create a password from root@localhost
UPDATE mysql.user SET password=password('whateverpasswordyoulike')
WHERE user='root' AND host='localhost';
exit
步骤05)重新启动mysql
Step 05) Restart mysql
net stop mysql
<wait 10 seconds>
net start mysql
第06步)以root身份使用密码登录
Step 06) Login as root with password
mysql -u root -p
从那里你应该很好.
注意:请删除匿名用户!!!
这篇关于MySQL:错误1227(42000):访问被拒绝-无法创建用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!