EXPORT MYSQL DATABASE USING TERMINAL
Steps
- Run the following command in the terminal to export the database.
mysqldump -u username -p database_name > database_name.sql- Replace
usernamewith your MySQL username. - Replace
database_namewith your database name. - It will ask for the MySQL password, enter the password and press enter.
- Replace
- Check the database_name.sql file in the current directory.
ls -l database_name.sql
Additional Information
-
Using SSH, you want to download the exported database file to your local machine, you can use the following command.
scp username@server_ip:/path/to/database_name.sql /path/to/local_directory- Replace
usernamewith your SSH username. - Replace
server_ipwith your server IP address. - Replace
/path/to/database_name.sqlwith the path to the exported database file. - Replace
/path/to/local_directorywith the path to the local directory where you want to download the database file. - It will ask for the SSH password, enter the password and press enter.
- Replace
-
pwdcommand is used to print the current working directory. -
lscommand is used to list the files and directories in the current directory. -
ls -lcommand is used to list the files and directories in the current directory with detailed information. -
scpcommand is used to copy files between hosts on a network.