mysqldump import code example

Example 1: linux command line import mysql database

# if your database is not locally hosted
mysql -u username -p -h dbhost dbname < filename.sql

Example 2: import database through command line

mysql -u username -p database_name < file.sql

Example 3: mysql dump restore

mysql -u [user] -p [database_name] < [filename].sql

Example 4: mysqldump

# Syntax
mysqldump -u [username] -p [database-to-dump] > [database-to-receive]

# Pipe it! Exporting DB from external host
mysqldump -u [username] -P [port] -h [host] [database-to-dump] | mysql -u root -h 127.0.0.1 [database-to-receive]

# Export specific tables by typing the name after the targeted DB
mysqldump -u [username] -P [port] -h [host] [database-to-dump] [tabl1] [table2] [table3] | mysql -u root -h 127.0.0.1 [database-to-receive]

Example 5: install mysqldump

# Mysql
sudo apt-get install mysql-client
# MariaDB
sudo apt-get install mariadb-clients

Example 6: import mysql database command line

Source : https://www.programmingquest.com/2018/08/how-to-export-mysql-database-using.html
open cmd
set mysql path in cmd
	set path=c:\wamp\bin\mysql\mysql5.6.17\bin
For database import (Restore): 
	mysql -u YourUser -p YourDatabaseName < filename.sql

Tags:

Sql Example