MilesWeb Hosting Forum

Web Hosting Technical Support => How To's => Topic started by: kunal.m on June 13, 2016, 03:43:39 PM

Title: How to import MySQL database
Post by: kunal.m on June 13, 2016, 03:43:39 PM
Hi All,

There are multiple ways by which you can import the contents of a MySQL database. Below are the two method you can import MYSQL database.
1. Importing Databases via phpMyAdmin

Quote
    Go to phpMyAdmin
    Click the new database name in the top left (optional)
    Click Import in the main area of phpMyAdmin
    Browse for the .sql file on your computer and click Go

1. Importing Databases via Command Line (SSH)

If you are not aware how to connect ssh. Please check the below for information on how to get connect ssh:

How To Connect Server Via SSH (https://www.milesweb.com/forums/how-to's/how-to-connect-server-via-ssh/)

To import your database after you have logged in to your account with SSH

1. Upload your database to your home directory.
2. If the database does not exist, please create a database, a user, and give the user full privileges to the database.
     Note the username and password.

If you are not aware how to create database. Please check the below for information on how to create database:

How to create a database form cPanel. (https://www.milesweb.com/forums/how-to's/how-to-create-a-database-form-cpanel/)

3. Log into your server via SSH.
4. Use the ls -l command to verify that the file is in your current directory.
5. If the file is not present, upload/move the file to the correct directory, or navigate to the directory where the file is located.
6. Enter the following command, replacing 'user_name', 'database_name, and 'file.sql' with the correct values for your database and file:
Quotemysql -p -u user_name database_name < file.sql

7. You will be prompted for your database user password, and then your database will be imported.

That's All....!!! :)