Created
March 30, 2009 14:44
-
-
Save meleyal/87820 to your computer and use it in GitHub Desktop.
MySQL recipes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#login | |
mysql -u <user> -p | |
# list all databases | |
show databases; | |
# 'open' a database | |
use <database_name>; | |
# list all tables | |
show tables; | |
# list table schema | |
describe <table_name>; | |
# show table content (with human-friendly formatting) | |
select * from <table_name> \G | |
# ditto, but set a limit | |
select * from <table_name> limit 1 \G | |
# delete all tables | |
mysqldump -u[USERNAME] -p[PASSWORD] --add-drop-table --no-data [DATABASE] | grep ^DROP | mysql -u[USERNAME] -p[PASSWORD] [DATABASE] | |
# export a dump file | |
mysqldump <database_name> > file.sql | |
# export a dump file from another db server | |
mysqldump -u <user> -p -h <server> <database_name> > file.sql | |
# import a dump file | |
mysql -u <user> -p <database_name> < file.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment