How do I export a .sql file via the command-line?
If you've set up SSH access for a package, then you can use one of two methods to export a MySQL database via the CLI.
If needed, please see our guide on how to connect to your package via SSH.
MySQL CLI
To export a SQL file via the command line, you can use the mysql command. Here’s how.
mysqldump -h hostname -u username -p database_name > file.sql
Replace hostname with your database server name.
Replace username with your database username.
Replace database_name with the name of the database where you want to export the SQL file from.
Replace file.sql with the path to the SQL file you want to export to.
After entering the command, you'll be prompted to enter the password for the specified username.
Enter the correct password, and the export process will begin.
Make sure the SQL file contains valid SQL commands and is in the correct format for the database you're using.
If the export is successful, you should be able to see the sql file within the directory.
WP CLI
To export a SQL file using the WP-CLI tool, you can follow these steps. WP-CLI is a command-line tool for managing WordPress installations, and it includes a command for exporting databases.
wp db exportThis command will create a SQL dump of your database in the WordPress installation folder.
