MySQL Command Line – Setting up a new database and user


From the command line start up mySql;

mysql -u root -h localhost -p

you will be prompted to enter your root password.  Once you’re in you can go ahead and create the database;

CREATE DATABASE <data_base_name>;

BAMM- that’s your database done – you can see this by typing;

SHOW databases;

Next add a user and grant all privileges to that new database (and only that database);

GRANT ALL ON <data_base_name>
.* TO <user_name>@localhost IDENTIFIED BY '<password>';

Or, to be more specific (and secure!)

GRANT SELECT , INSERT , UPDATE , DELETE , CREATE , DROP , ALTER ON <data_base_name> . * TO <user_name>@localhost IDENTIFIED BY '<password>';

The last line you need before you can use the account is;

FLUSH PRIVILEGES; 

The PCTools.com website has a handy page for generating random passwords.

Note, the user created here will only have access when logging on from the local machine.  If you want a user which can logon from anywhere replace localhost with %.  Alternativly you can also specify specific ip addresses.

  1. No comments yet.
(will not be published)


I absolutely love these. They came at the lace wigs are good quality, and very soft. Absolutely love these extensions. I just love this hair. Hair came on time, I waited until after hair extensions uk very full, no shedding and it is been installed for 3 weeks now and yes I jus ordered 3 more bundles. Lol. I definitely recommend this company for your bundles ladies. They are soft, hair bundles on the head for human hair wigs and I would continue to recommend them. I have thinner hair so they cover and blend nicely.