
The top ten of most used MySQL command line commands.
Below you can find a useful list of the most common MySQL command line commands.
- MySQL Login: Use mysql --user=[user_name] --password=[your_password] [db_name] or mysql -u [user_name] --password or mysql -u [user_name] -p[your_password] [db_name] to login into the command line version of MySQL.
- Dump Database The command mysqldump -u [user_name] -p[your_password] [db_name] > /var/www/host/database.sql creates a mysql dump of the requested database and writes it to the hdd.
- Execute external MySQL code To execute a predefined file of sql commands, you can use mysql -u [user_name] -p[your_password] [db_name] < my_file.sql.
A few other very useful but basic sql commands, often uncommon by phpmyadmin users, are show databases; for a list of available database, use [db_name]; to switch to another database, show tables; for a list of tables within a particular database and describe [table_name]; to receive the table structure.
Would you like to comment?
Fields with * are obligatory.
Save


