Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grant all privileges to all users on a host in mysql

Tags:

mysql

How to grant all privileges to all users in 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.

like image 708
S Khurana Avatar asked May 11 '16 05:05

S Khurana


3 Answers

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.

like image 136
Rahul Tripathi Avatar answered Oct 20 '22 17:10

Rahul Tripathi


This is working for all my MySQL users irrespective of their hostname and Ips.

GRANT ALL ON <yourdbname>.* TO ''@'%' IDENTIFIED BY 'yourdbpassword';
FLUSH PRIVILEGES;
like image 20
milind bhavsar Avatar answered Oct 20 '22 16:10

milind bhavsar


This should work:

GRANT ALL PRIVILEGES ON 'database'.'table' TO '%'@'1.2.3.4' WITH GRANT OPTION;
like image 32
Adrian Avatar answered Oct 20 '22 18:10

Adrian