MySQL Cheat Seet

# login to mysql
~$ mysql -u username -p

# create database
mysql > create database database_name;

# focus to database
mysql > use database_name;

# logout
mysql > exit

# import
~$ mysql -u username -p password database_name < filename.sql

# export / dump all database
~$ mysqldump -u username -ppassword –all-databases > dump.sql

# dump more than 1 database
~$ mysqldump -u username -ppassword –databases db_name1 [db_name2 ...] > dump.sql

# dump structure only
~$ mysqldump -u username -ppassword -no-data database_name > dum_no_data.sql

Published by


just to remember what i had known :)

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s