How To Import MySQL File To Your MySQL Database Via SSH
We’ve recently created a WordPress site and we want to move the database for this site from our production server to our Remote MySQL Server. To do this we need to take a copy of the database and import the MySQL file on our remote database server. So there are two ways to get a copy of your database, via the GUI if you use cPanel or DirectAdmin. Or via the command line using a console.
Download MySQL Database
Let’s get a copy of the database. If you use cPanel or something with PHPmyAdmin then you can easily export the database which will download a .sql file to your computer. For the purpose of this guide, we have exported our database and placed it in our public_html. We can then use wget to grab a copy of it. We’re assuming you already have a copy of your database in .sql format on your database server
To download a dump or copy of your MySQL database via the command line you can use the mysqldump command in the console. State the database user and the database name. Where you would like the database backup to be placed on your NVMe VPS Instance.
mysqldump -udb-user -p datab > database-dump.sql
Import MySQL File
So, our exported MySQL database is called deltasq_wp114.sql. We are going to import the sql file to a database we have already created on our MySQL server. The database is called deltadbbeta. So let’s import the database.
mysql -u username -p database_name < deltasq_wp114.sql
We specify the username of the MySQL user, the MySQL database name and the file name of our exported database. The instance will now import the sql file to your database.
[email protected]:~# mysql -u delta -p deltadbbeta < deltasq_wp114.sql
Enter password:
Next, you can now update your MySQL database details in any software programs like WordPress. That is the process of importing a database dump to a MySQL database.
How was this article?
You might also like
More from MySQL/MariaDB
WordPress High Availability using MySQL Replication and HyperDB
WOKE STATEMENT: We use the terminology Master + Slave in this post. Whilst some may feel we should use …
Load Balance HAProxy MySQL Connections Over MySQL Cluster
Recently, we went through the process of load balancing HTTPS connections with HAProxy. In this article, we are going to …
How To Configure MySQL Master-Master Replication
MySQL Master-Master replication evolved from the standard Master-Slave replication. In a Master and Slave environment, database changes are made on …
1 Comment
[…] this point, you could import an existing MySQL database to your server. You should now be ready to use your remote MySQL server. To test our setup we have […]