1

I initially posted a question regarding why I was given a syntax error message here. I then created the user usermail with (I admit I misused IDENTIFIED BY but I don't think it matters in this case:

mysql> CREATE USER 'usermail'@'127.0.0.1' IDENTIFIED BY 'usermail';
Query OK, 0 rows affected (0.02 sec)

I then retried what I was initially trying to run.

mysql> GRANT SELECT ON servermail.* TO 'usermail'@'127.0.0.1' IDENTIFIED BY 'mailpassword';
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 'mailpassword'' at line 1
mysql> GRANT SELECT ON servermail.* TO 'usermail' IDENTIFIED BY 'mailpassword';
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 'mailpassword'' at line 1
mysql> GRANT SELECT ON servermail.* TO 'usermail'@'127.0.0.1' IDENTIFIED BY 'mailpassword';

I am still getting the exact same error. How was my question a duplicate? Or did I not follow the directions properly?

sangstar
  • 81
  • 1
  • 3
  • `syntax to use near 'mysql >` That indicates that you included the prompt `mysql>` in your SQL command, an errant copy/paste. – Michael Berkowski Jan 05 '21 at 21:00
  • @MichaelBerkowski I've typed it in manually without `mysql>` and still no dice. I'll remove that errant example though. – sangstar Jan 05 '21 at 21:03
  • 1
    Get rid of everything starting with `IDENTIFIED BY` in your `GRANT` statements. You only use that when creating the user. – Barmar Jan 05 '21 at 21:05
  • Older versions of MySQL allowed you to use this in `GRANT` because it would create the user if necessary. Recent versions got rid of that feature. – Barmar Jan 05 '21 at 21:06
  • @Barmar So I don't need `mailpassword`? Why not? Is a password not necessary here? – sangstar Jan 05 '21 at 21:08
  • You set the password in the `CREATE USER` command. A user can't have multiple passwords. – Barmar Jan 05 '21 at 21:09
  • If you want to change their password, use `ALTER USER`. – Barmar Jan 05 '21 at 21:09
  • @Barmar Ah I see, so that initial statement is supposed to create a user, give it a password, and grant it a role in the same line, which is no longer possible. – sangstar Jan 05 '21 at 21:15
  • Yes, that's correct. – Barmar Jan 05 '21 at 21:16

0 Answers0