mysql dump a full backup

Create a table:

MariaDB [xuegod]> create database xuegod;
MariaDB [xuegod]> use xuegod;
MariaDB [xuegod]> create table student(id int(20),name char(40),age int);

View table structure

MariaDB [xuegod]> desc student;

 

Basic Operation

create table student (id int (20 ), name char (40), age int); insert data
INSERT INTO Student values (2, 'LIS', 24), (. 3, 'Wange', 26 is);
SELECT * from Student ; see data sheet

 


select * from student \ G # field displayed in rows
select * from HA.student; # cross-database query
delete from students where id = 3; # delete data
delete from students where age is null; delete adge empty content
update students set sex = 'M' where id = 2; update
select distinct name, age from student; # deduplication query
select id, name, age from student where id> 3 and age> 25; # many conditions
select * from students where stname = 'zhangsan' and (or Age Age = 21 is = 24);
SELECT * WHERE from Student binary name = 'JK'; # default is not case-sensitive queries distinguish

select distinct id from student order by id asc; # ascending
select distinct id from student order by id desc; # descending

help show;

 

 

 

mysqldump -uroot -p123456 -B migration library name> .sql export name

Backup and restore databases

Backup :mysqldump -u用户名 -p密码 数据库名>生成的脚本路径

//末尾没有分号,也不要登录
mysqldunp -uroot -p123 school>C:a.sql


Recovery :mysqldump -u用户名 -p密码 数据库名<生成的脚本路径

或者:登录之后,切换到需要恢复的数据库,输入:source 生成的脚本路径

 

//要先删除school数据库,再重新创建数据库,这两步需要登录
//执行下面sql语句,不要登录,末尾没有分号
mysql -uroot -p123 school<C:a.sql


Garbage problem

Find your mysql installation directory to find my.ini file, but bin directory at the same level, modify the following code:

[mysqld]

character-set-server=utf8 [client] default-character-set=utf8 [mysql] default-character-set=utf8 

After modifying, not only to re-connect to the database, the database must be restarted

 

1. backup the entire database, including tables and data structures:

    Format: mysqldump -h database ip -u username -p database name> d: XX.sql (file storage path)
     
    Example: mysqldump -h132.72.192.432 -uroot -p test> /home/code/test.sql;

then enter the password, note that this command need not be performed in the mysql terminal is required only to the linux console.

2. database recovery

if necessary restored using the backup data into the mysql command line, using the following command operations:

Source /home/code/test.sql

 

Guess you like

Origin www.cnblogs.com/wwtao/p/11572836.html