I read so much bullshit about how to create a mysql user and database, in most cases it’s not just inefficient but also wrong.
So here is the best and most efficient way to create a MySQL database and user with password:
1 2 |
CREATE DATABASE mydatabase; GRANT ALL ON mydatabase.* TO 'myuser'@'localhost' IDENTIFIED BY 'mypassword'; |
Done.
No FLUSH PRIVILEGES.
No create user, then database then give user access then update password.
Just those 2 lines. Nothing more.