MySQL:ERROR 1227(42000):访问被拒绝 - 无法创建用户

时间:2022-12-09 19:19:26

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?

表用户在哪里?

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;并收到以下错误消息:错误1227(42000):访问被拒绝;您需要(至少一个)此操作的CREATE USER权限

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的事实是否与错误消息有关?

1 个解决方案

#1


84  

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 !!!

CAVEAT:请删除匿名用户!

#1


84  

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 !!!

CAVEAT:请删除匿名用户!