Useful MySQL commands
Useful MySQL commands for working from the command line. This works for both Windows and Linux environments; open a command window and use the following command to start and login to MySQL. After hitting Enter
, you will be prompted to enter your password:
mysql -u your_username -p
The following command will show all databases:
show databases;
The following command will select a database to use:
use database_name;
The following command will show all tables:
show tables;
To import a database from a MySQL file, use the following command:
source c:\path\to\your\database_file.sql;
To export a database to a specified location, use the following command:
mysqldump -u your_username -p database_name > /var/www/website_path/db_backup.sql;