mysql database commands

To login:

mysql -u root -p

To List all databases

show databases;

to create new database

create database [databasename];

Switch to a database.

use [db name];

To see all the tables in the db.

show tables;

To delete a db.

drop database [database name];

To delete a table.

drop table [table name];

to start, stop, restart mysql in ubuntu

/etc/init.d/mysql stop

/etc/init.d/mysql start

/etc/init.d/mysql restart

to show queries running in db

show processlist;
to create new user in database

grant all on databasename.* to username@’localhost’ identified by ‘password’;


About Kapil Chugh

In love with PHP and tweaking WordPress. Hungry for Open Source and new technologies. Honest. God-fearing. Happiest when solving problems.
This entry was posted in Mysql and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s