How to Import a MySQL Database
I wish to import a MySQL database. How can I do it?
Thanks!
Instructions to import a MySQL database using SSH
- Log into your Web space using an FTP/ SFTP client. You will need to know your username and password.
- Find your existing .SQL database and upload it to your Web space using your FTP/ SFTP client. Make sure you remember the path to where you upload this file.
- You may also use SCP client instead of an FTP/ SFTP client to upload the file, if your web host supports it.
- Log into your Web space using a SSH client you are comfortable using. You will need the username and password assigned to you by your Web-hosting provider.
- Your web hosting provider might give you access via Telnet instead of SSH. That should be fine as well. Login using a Telnet client in this scenario.
- Enter the following into the command line, using your own database name, file name, username and password instead of the words in capitals.
mysql -uUSERNAME –pPASSWORD DATABASENAME < /PATH/TO/DATABASEBACKUPFILE.sqlFor example, if my username was "nibbleguru", my password "example", my database name "testdb" and the absolute path to my file "/home/nibbleguru/my_db_backup.sql", I would type:
mysql –unibbleguru –pexample testdb < /home/nibbleguru/my_db_backup.sql
Instructions to import a MySQL database using phpMyAdmin
- Most good web hosting providers provide access to a program called phpMyAdmin, which lets you manage your MySQL database.
Log onto the phpMyAdmin page from your Web space. You will need the username and password assigned to you by your Web-hosting provider. - Select the database you wish to import the old data into from the drop-down Database Selection box on the left of the page.
- Click the SQL tab toward the top of the page that opens.
- Click the Browse button located toward the bottom of the page.
- Find the .SQL file where it is saved on your hard drive, select it and click "Open".
- Click the Go button. The data in your SQL file has now been imported into your database.
If your hosting provider doesn't provide you with access to phpMyAdmin then you can also install one of your own.
Post new comment
2 Steps to Post a New Problem

