November 9, 2007
Whilst looking on the internet for something i came across this nice and simple guide to creating a MySql database.
In order to be able to use a database, you need to create a new database, give access permission to the database server, to a database user and finally grant all rights to that specific database to this user.
I am going to create a database called toodles
First of all you need to make sure you have mysql installed
it is a pretty vital part to this!
You need to log in to MySQL, as root
So from the terminal type;
$ mysql -u root
If you need to enter a password for root, then you will need to enter; NOTE you do not need to type $
$ mysql -u root -p
Enter password:
This has now logged you in, you will now need to create a database, so enter the command as follows;
mysql> create database toodles;
You should see this underneath
Query OK, 1 row affected (0.00 sec)
You now need to create a user of the database, for this i will call the user Ted
mysql> grant usage on . to ted@localhost identified by ‘tedpasswd’;
Query OK, 0 rows affected (0.00 sec)
Now you will need to grant all usage rights to the user Ted
mysql> grant all privileges on toodles.* to ted@localhost ;
Query OK, 0 rows affected (0.00 sec)
Simple as that, saved me alot of time as i didnt even have a clue how to log into MySQL
Leave a Reply