mateuszs
mateuszs

Reputation: 165

How to grant all privileges to a user in MySql

I am connected as a root user in MySql. Root user has GRANT and

grant all privileges on *.* to 'root'@'localhost' with grant option;

went through last time I did it without error code returned.

When I however change root to sqluser there is: "Error Code: 1410. You are not allowed to create a user with GRANT "

Earlier action:

grant grant option on *.* to 'sqluser'@'%'

and it didn't return error code. However as I ran query with localhost there is error code with number 1410.

I have MySql 8.0 installed.

How can I make grant all privileges go through?

Upvotes: 3

Views: 23148

Answers (2)

TakUnderhand
TakUnderhand

Reputation: 111

I had the same problem when setting up a new mysql database, at the point of adding the first user.

I have found my problem was resolved by removing the @'localhost' from the GRANT.

This works:

mysql> grant all privileges on *.* to 'laravel_user';

Query OK, 0 rows affected (0.10 sec)

This does not:

mysql> grant all privileges on *.* to 'laravel_user'@'localhost';

ERROR 1410 (42000): You are not allowed to create a user with GRANT


mysql version:
$ mysql -V
mysql  Ver 8.0.12 for osx10.14 on x86_64 (Homebrew)

I was following this guide to set up the database:
https://www.a2hosting.co.uk/kb/developer-corner/mysql/managing-mysql-databases-and-users-from-the-command-line

Upvotes: 9

AbdulAhmad Matin
AbdulAhmad Matin

Reputation: 1146

test this code.

GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost' REQUIRE NONE WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;

Upvotes: -2

Related Questions