Simran Kaur Simran Kaur - 6 months ago 41
SQL Question

Grant all privileges to all users on a host in 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.

Answer

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.