A
A
Andrey Pushkin2018-05-26 19:51:03
MySQL
Andrey Pushkin, 2018-05-26 19:51:03

What's wrong with the grant command?

I don’t understand where I messed up, mb who will see?

mysql> GRANT REPLICATION SLAVE ON *.* TO 'root'@'%' IDENTIFIED BY my_password;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY my_password' at line 1

UP:
I tried to enter without a password, but it turned out like this
mysql> GRANT REPLICATION SLAVE ON *.* TO 'root'@'%';
ERROR 1410 (42000): You are not allowed to create a user with GRANT

It's interesting how it is, if I'm sitting behind this
UPP user.
So that they don't take me for a fool, I copied the user's command from the comments, which worked for him.
mysql> GRANT REPLICATION SLAVE ON *.* TO 'root'@'%' IDENTIFIED BY 'my_password';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY 'my_password'' at line 1

Then I changed the username
mysql> GRANT REPLICATION SLAVE ON *.* TO 'admin'@'%' IDENTIFIED BY 'my_password';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY 'my_password'' at line 1

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya S, 2020-04-22
@Stalinko

In MySQL 8, it was forbidden to automatically create a user with the GRANT command.
Now you need to first explicitly create a user with the command:

CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'secret';

and only then give it rights:
GRANT REPLICATION SLAVE ON *.* TO 'myuser'@'localhost';

D
Dave Hornigan, 2018-05-27
@DeyvHorni

The first error was 100% due to the fact that the password is not wrapped in quotes, and the second is not enough rights to create users using GRANT.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question