Welcome, Guest Login

Support Center

Import MySQL Database

Last Updated: Jun 09, 2014 06:15PM EDT

Less often than with MSSQL databases, you may have to import a DB for a customer directly on the SQL server because they are unable to upload it themselves via phpmyadmin.

When this happens, you will need the following:

  • The SQL server the DB is hosted on
  • A copy of the DB being restored <restore db>
  • The name of the DB being restored to <destination db>
  • the mysql root password - not the same as the server root password

With this information, you can perform the import as follows:

  1. Log into the DB server over ssh
  2. Move the DB you are restoring to the DB server
    1. You can FTP it or request they host it for you and get it from a URL
  3. If the DB is in a tar or gzip, you will need to decompress it
    1. gzip
      • gzip -d filename.gz
    2. tar
      • tar xvzf filename.tar.gz
      • tar xvjf filenametar.bz2
      • tar xvf filename.tar
  4. Once decompressed, you should have a .sql file. Issue the following command
    • mysql -u root -p 'destination db' < 'restore db.sql'
    • ex: mysql -u root -p iama_database < iamanew_db.sql
  5. You will be prompted for the password, this is the mysql password
    • Enter password: 
      • If you don't know the password, it can be found with the following command
        • cat ~mysql/.my.cnf |grep password
  6. Submit the password and wait until the prompt returns. There is no confirmation or completion message

That is all. Once completed, let the customer know the DB has been restored and log out of the server.

Contact Us
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
Invalid characters found