在mysql中为所有用户授予所有特权。

时间:2022-04-30 08:53:17

How to grant all privileges to all users in mySQL ?

如何将所有特权授予mySQL中的所有用户?

GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'1.2.3.4' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;

What do I replace username with in order to allow it for every user on the given IP?Even if it is '' i.e no username at all in input ?

我要用什么来代替用户名呢?即使是“我”。输入中没有用户名?

I tried * and % in username but that did not help.

我尝试了*和%的用户名,但这没有帮助。

3 个解决方案

#1


2  

You can try like this:

你可以这样尝试:

GRANT ALL PRIVILEGES ON *.* TO ''@'localhost' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;

The manual says:

手册说:

In this case, any user who connects from the local host with the correct password for the anonymous user will be permitted access, with the privileges associated with the anonymous-user account.

在这种情况下,任何从本地主机连接到匿名用户的正确密码的用户都将被允许访问,其特权与匿名用户帐户相关联。

#2


0  

This should work:

这应该工作:

GRANT ALL PRIVILEGES ON 'database'.'table' TO '%'@'1.2.3.4' WITH GRANT OPTION;

#3


0  

Wild card does not work for user in mysql grant privilege command.

在mysql授予特权命令中,通配符不适用于用户。

If you know list of users then yOU can try :-

如果你知道用户名单,那么你可以试试:-

 GRANT ALL PRIVILEGES ON *.* TO 'user1'@'1.2.3.4',
 'user2'@'1.2.3.4',
 'user3'@'1.2.3.4',
 'user4'@'1.2.3.4',
 'user5'@'1.2.3.4',
 'user6'@'1.2.3.4';

#1


2  

You can try like this:

你可以这样尝试:

GRANT ALL PRIVILEGES ON *.* TO ''@'localhost' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;

The manual says:

手册说:

In this case, any user who connects from the local host with the correct password for the anonymous user will be permitted access, with the privileges associated with the anonymous-user account.

在这种情况下,任何从本地主机连接到匿名用户的正确密码的用户都将被允许访问,其特权与匿名用户帐户相关联。

#2


0  

This should work:

这应该工作:

GRANT ALL PRIVILEGES ON 'database'.'table' TO '%'@'1.2.3.4' WITH GRANT OPTION;

#3


0  

Wild card does not work for user in mysql grant privilege command.

在mysql授予特权命令中,通配符不适用于用户。

If you know list of users then yOU can try :-

如果你知道用户名单,那么你可以试试:-

 GRANT ALL PRIVILEGES ON *.* TO 'user1'@'1.2.3.4',
 'user2'@'1.2.3.4',
 'user3'@'1.2.3.4',
 'user4'@'1.2.3.4',
 'user5'@'1.2.3.4',
 'user6'@'1.2.3.4';