Here is a quick example of how to create a database, assign a new user and set their password.
Connect to MySQL server as user “root” (you will be prompted for a password)
mysql -h localhost -u root -p
The “mysql>” prompt will now appear. Create new database… we’ll call it “orders”
CREATE DATABASE orders;
Give user (named “fluffy”) full permissions
GRANT ALL PRIVILEGES ON orders.* TO fluffy@localhost;
Set password for the user (change “supersecretpassword” to the password you desire)
SET PASSWORD FOR fluffy@localhost = PASSWORD('supersecretpassword');
Cleanup
FLUSH PRIVILEGES;
Keep in mind that you may want to modify your user’s permissions depending on what they need to do. As always, only give as much permission as they NEED to have. In the example above we are giving them access to everything.
[…] You may also want to refer to this tutorial… Create MySQL database and Add New user (command line) […]