3

I'm running command grant all privileges on *.* to 'username'@localhost identified by 'strong password';, but I get the error:

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 'strong password'' at line 1.

I can add a user separately and then assign it the privileges on the database, but I'd like to add the user and assign privileges in a single command. MySQL version:

| version                  | 8.0.23-0ubuntu0.20.04.1       |
| version_comment          | (Ubuntu)                      |
| version_compile_machine  | x86_64                        |
| version_compile_os       | Linux                         |
| version_compile_zlib     | 1.2.11                        |
mustaccio
  • 28,207
  • 24
  • 60
  • 76
Sajid Maqsood
  • 39
  • 1
  • 3

1 Answers1

5

GRANT has no option for password anymore in mysql 8 see manual

CREATE USER 'username'@'localhost' IDENTIFIED BY 'strong password';
GRANT ALL ON *.* TO 'username'@'localhost';
nbk
  • 8,699
  • 6
  • 14
  • 27