Create MySQL Database

MySQL is one of the most popular free database for websites. To start developing any website with dynamic content, one needs a database. A MySQL database can be created either from Command-line or with a free to use web interface, phpMyAdmin.

Creating Database from Command-line

1. Assuming that MySQL is installed, first step is to login with root user.

mysql -u root -p

-p switch is for the user password for ‘root’ user.

2. Create database

mysql> create database refulz;

3. Its better not to use the root user as the database user, so we are required to create a user ‘sql_user’  and allow the user to be able to login to the localhost with password ‘pass’

mysql> grant usage on refulz.* to sql_user@localhost identified by ‘pass’;

4. Now, we may assign all privileges on database refulz to the sql_user.

mysql> grant all privileges on refulz.* to sql_user@localhost ;

Thats all the new database is ready.

Alternatively, the simple interface of phpMyAdmin can be used to perform above 4 steps. The screens are attached below:

1. Create Database

2. Assign Privileges

3. Assign Database privileges

The interface makes it really simple to create tables and perform other operations. For commands, I will cover more commands in next posts.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>