Home > Database > Mysql Tutorial > body text

How to import and export mysql database under linux

怪我咯
Release: 2017-04-05 13:16:11
Original
1253 people have browsed it

1. Use the mysqldump command to export the database (note the installation path of mysql, which is the path of this command):

1. Export data and table structure:
mysqldump -u username -p password database name > database name.sql
#/usr/local/mysql/bin/ mysqldump -uroot -p abc > abc.sql
After pressing Enter, you will be prompted to enter Password

2. Export only the table structure
mysqldump -u username-ppassword-d database name> database name.sql
#/usr/local/mysql/bin/ mysqldump -uroot -p -d abc > abc.sql

Note: /usr/local/mysql/bin/ ---> mysql data directory


2. Import the database
1. First create an empty database
mysql>create database abc;

2.Import the database
Method 1:
(1)Select the database
mysql>use abc;
(2)Set database encoding
mysql>set names utf8;
(3)Import data (note the path of the sql file)
mysql>source /home/abc/abc.sql;
Method two:
mysql -u username -p password database name < database name.sql
#mysql -uabc_f -p abc < abc.sql

It is recommended to use the second method method to import.

Note: There is command line mode and sql command

The above is the detailed content of How to import and export mysql database under linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!