Here ,we will see how to import and export database or table (sql file) in MySQL by using command line or prompt (SSH).

 

With the help of SSH or Command Line Its good way to manage the files and databases on your account.By using simple and easy command you can easily import and export a MySQL database file into a existing database.

How-to-export-import-mysql-database-by-using-command-line-SSH

Sometime this way is very helpful when you want to import large file to existing database.By use of command line (SSH) , File and MySQL data transfer will be very fast and easy compared to manual with help of any ftp client or mysql client.

Import Mysql :

Using SSH , Execute the following command: :

1>This command needs a SQL (.sql) file containing data in form of insert statements for table table_name.

2>All the Insert statements will be executed and the data will be loaded.

3>Your .sql file (which you want to import) must be on server.

4>Database must be created before this operation.If not please create Database on same server.

5> Replace username, password and database_name with your MySQL username, password and database name.

6>here after running above command ,you will be prompted for password,Now you have to give password for given username of Database

7>Before Executing above command make sure that you have backup of this DB.

Export MySQL :

Using SSH, execute the following command:

 

 

1>Database must be created before this operation.If not please create Database on same server.

2> Replace username and databaseName with your MySQL username and database name.

3>here after running above command ,you will be prompted for password,Now you have to give password for given username of Database

4>path/dbname.sql => This is newly created file path with dumped query data.

5>Before Executing above command make sure that you have backup of this DB.

That it !! Please subscribe us to get more latest or tricks on web development.

You can see our PHP Tutorial for fresher and experience developer: 

<<<<< PHP Interview questions and answers for freshers and experienced developer

<<<<< PHP tutorial for beginner Day 4 –  Echo and Print operation in PHP

<<<<< PHP tutorial for beginner Day 3 –  variable scope and type of variable

<<<<< PHP tutorial for beginner Day 2 – Syntax overview and tag

<<<<< PHP tutorial for beginner Day 1 – Introduction and Installation.