Dominique De Cooman
Published on Dominique De Cooman (https://dominiquedecooman.com)

Home > Linux: how to export and import a database

Dominique De Cooman
Tuesday, April 29, 2008 - 23:02
linux [1]
import [2]
export [3]

Go to the location on your server where your file is using cd command

cd /var/www 

To see your location in the server directory tree use pwd command
pwd

For a list of all your databases:
$ mysql -u root -h localhost -p -Bse 'show databases'

To dump your database:

$ mysqldump -u root -h localhost -pmypassword faqs | database_name -9 > database_name.sql

To import your database:

mysql -u user -ppassword --default-character-set=utf8 database < "database_name.sql"

If you have a zip file you need to unzip it

gunzip name_file


Source URL: https://dominiquedecooman.com/blog/linux-how-export-and-import-database

Links
[1] https://dominiquedecooman.com/blog-topics/linux-0
[2] https://dominiquedecooman.com/blog-topics/import
[3] https://dominiquedecooman.com/blog-topics/export