Import and export of mysql data

one. Import of data.

There are many ways to import data, and here is the one I think is easier to use.

 1. Enter the database:

start with password
$mysql -u root -p
Then enter the password.

Boot without password
$mysql

  2. Using the database:

$use Database_name

 

  3. Data import:

source /home/lenovo/download/xxx.sql

 

For example: your file is in /home/lenovo/download/xxx.sql that path => "/home/lenovo/download/xxx.sql"

In this way, general data import can be solved.

 

two. Data output.

   1. Export the database:

mysqldump -u root -p beta_blind > beta_blind.sql

 

 beta_blind represents the name of the database, beta_blind.sql represents the name of the exported file.

  

   2. Export a table in the database:

mysqldump -u root -p beta_blind user_info > beta_blind.sql

 user_info represents the table name. 

 

If no other work is required, the exported file name should preferably be a file with a suffix of .sql. This makes it easier to import later.

   

three. Other common commands for the database:

   1, Display the database:

show databases;

   2, Display the table in the library:

show tables;

 The premise is that you have already opened a database, open the database:

use mysql;

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327071421&siteId=291194637