Sometimes, you need to import an SQL file into your website's database. This could be due to a number of reasons like migration, backup, or testing. Here at 10Web, we provide two methods for importing an SQL file: via phpMyAdmin and via SSH and SFTP. We'll guide you through both methods.
Importing via phpMyAdmin
Note:
The SQL file should have the proper format.
We recommend trying this method first, as it's user-friendly and accessible right from your 10Web dashboard.
Here are the steps:
- Go to the 10web dashboard
- Click Manage on the website you want to import the database to
- Click on Credentials in the left menu
- Click on Open MySQL in the Database Access section
- Copy and paste the username and password found on the Credentials page and click Log in
- Select the database from the left menu in phpMyAdmin
- Click the Import tab
- Click Choose File under the Files to Import section
- Click Go in the bottom right corner to begin the import
If you experience an error using this method, it may be due to the SQL file’s size. In that case, please try to import the file using SSH and SFTP.
Importing via SSH and SFTP
This method is a bit more technical, but it will handle larger SQL files effectively.
Before you start, ensure you have your SQL file ready and access to SFTP and SSH for your website.
Step 1: Upload your SQL file
The first step is to upload your SQL file to your website using SFTP (Secure File Transfer Protocol).
To accomplish this:
- Open your SFTP client software (for example, FileZilla)
- Connect to your website's server using your SFTP credentials
- Navigate to the /home/wplive/web/wp-live/ folder in your website's file directory
- Upload your SQL file (e.g., `example.sql`) into the wp-live folder
After this, your SQL file path will be /home/wplive/web/wp-live/example.sql.
Step 2: Import the SQL file via SSH
After uploading your SQL file, the next step is to import it into the database using SSH (Secure Shell).
Here's how to do it:
- Connect to your website's server using SSH.
- Run the following command: mysql -u MYSQL_USERNAME -h mysql.10web.site --binary-mode MYSQL_DB_NAME < /home/wplive/web/wp-live/example.sql
Important:
Please note that in the above command, you'll need to replace MYSQL_USERNAME and MYSQL_DB_NAME with the appropriate values from your wp-config.php file. Remember to change example.sql to your SQL file’s name.