patternsqlMinor
Why am I not able to add a user?
Viewed 0 times
whyuserablenotadd
Problem
I'm running command
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:
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 |Solution
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';Code Snippets
CREATE USER 'username'@'localhost' IDENTIFIED BY 'strong password';
GRANT ALL ON *.* TO 'username'@'localhost';Context
StackExchange Database Administrators Q#294205, answer score: 4
Revisions (0)
No revisions yet.