How I can Export/Import mySQL?

Asked By 40 points N/A Posted on -
qa-featured

I have tables in database I’m just wondering on how I can export/import my files,

Anyone can give steps on how this should be done?

SHARE
Answered By 0 points N/A #104563

How I can Export/Import mySQL?

qa-featured

There are two well know methods for exporting or importing Mysql databases. One of them is the SSH command line,while the other is the phpMyAdmin.

Please find the details of both methods as below:

Import/Export using command line (SSH):

Importing MySQL database:

  1. First the required file is uploaded into the Fast domain server (the file needs to  be in .sql format).
  2. Navigate to the .sql file,using the SSH .
  3. Execute the command provided below:

    • Mysql –p –u username db_name < file.sql

Note: -p will prompt for the password associated with the account. As in most cases, usernames hold most of the rights with respect to  the database. In case the username and password are not known, one can use the username and passwords  which were used for SSH.

Exporting MySQL database:

It is considered as the best way for backup.

  1. Using SSH, execute the command provided below:

    • mysqldump -u username -p db_name > dbname.sql
  2. When the password prompt comes, type the password and  then press the Enter key.
  3. Replace the password, username and database name with MySQL password, username, and database name.
  4. Executing the command, you will now be able to store your database backup in dbname.sql, and this can be later downloaded to your PC.

Import/Export using phpMyAdmin:

Note: This method works only if the size of the database is 50MB or below. For larger databases, SSH is the best way.

Importing MySQL database:

  1. Login to the ‘Fastdomain’ cPanel
  2. Select the phpMyAdmin, under the ‘Databases’ category.
  3. Select from the left column, the name of the database that you want to import.
  4. Click the "Import" tab that you see the top of the screen.
  5. Select the tab "File to Import", and click browse.
  6. Locate the .sql file on your computer. Once selected, click on GO, and the command would import your database.
  7. After the file selection is made, click GO and it will import your database.

Exporting MySQL database:

  1. Login to the ‘Fastdomain’ cPanel
  2. Select the phpMyAdmin, under the ‘Databases’ category.
  3. Select from the left column, the name of the database that you want to export.
  4. Click the "Export" tab that you see the top of the screen.
  5. Click ‘Select All’ or only the specific tables that you need.
  6. Check the ‘Save as file’ box, and enter a name.
  7. Press the Go button on the bottom right.

Related Questions