I am new to Ubuntu (server edition) and mysql.

How do I upload (import) an existing database with a MYSQL or (mysql.zip) extension that was downloaded from a web host (cPanel?)

I do not have any of the UI bells and whistles such as zPanel (although I tried to install it.) I did install phpMyAdmin with Ubunto but I do not know how to access it from a remote computer )In the past, I only used it with cPanel.)

My site will reside in /var/www.

I have installed mysql server Dist. 5.5.32. Thanks. :)


If you have downloaded the database as an SQL file then you can just import it using the command prompt and the mysql command.

Do it in these simple steps:

  1. Make sure the SQL file is unpacked as a text file with SQL commands inside
  2. Verify you're able to login to MySQL using the command prompt. You can simply type # mysql -p -u username database_name. You'll be asked for password and, if correct, you'll be accepted to your database.
  3. If you haven't created any new database to unpack your backup file in you can do it now (inside the MySQL command prompt) by typing create database MyNewDatabase;
  4. Now that you know you can login to the database you can "feed" the downloaded SQL file by changing the command in this way: # mysql -p -u username database_name < /tmp/download/db_backup.sql. Make sure you're not inside the MySQL command prompt but out in the normal command prompt when typing this command. You can simply type exit or quit to leave the MySQL command prompt.
  5. The database will then be imported into your local database. If it's a big database running this last command might take quite some time.

Some things to think of:

  • If you have a new installation and haven't added any users to MySQL then root is the username to use. But it's always recommended to add a separate user account in MySQL that you can use from scripts ect.
  • In my examples above I specified a database name. But if your backup script starts with use someotherdb; then someotherdb will be used instead of the database name you specify in the mysql command. To get around this, either open up the SQL backup file and remove the first line with use, or, when you create your backup, untick the box saying Include using (or something similar).
  • This is just how to install the database. You talked about "web site" also and that's a different thing. However, you need to update your website scripts to point to the new local database that you've created now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.