mysql dump 徹底備

建立表:mysql

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

查看錶結構linux

MariaDB [xuegod]> desc student;

 

基礎操做sql

create table student(id int(20),name char(40),age int); 插入數據
insert into student values(2,'lis',24),(3,'wange',26);
select * from student;查看數據表數據庫

 


select * from student\G #字段按行顯示
select *from HA.student;#跨庫查詢
delete from students where id=3;#刪除數據
delete from students where age is null; 刪除adge爲空的內容
update students set sex='M' where id=2;更新
select distinct name,age from student;#去重查詢
select id,name,age from student where id>3 and age>25;#多條件查詢
select * from students where stname='zhangsan' and (age=21 or age=24);
select * from student where binary name='jk';#區分大小寫查詢 默認不區分

select distinct id from student order by id asc;#升序
select distinct id from student order by id desc;#降序

help show;spa

 

 

 

 



亂碼問題

找到你的mysql的安裝目錄,找到my.ini文件,更bin目錄同級,修改以下代碼:命令行

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

修改完以後,不只是要從新鏈接數據庫,必需要重啓數據庫code

 

1. 對整個數據庫備份,包括表結構和數據:

    格式:mysqldump -h數據庫ip -u用戶名 -p 數據庫名 > d:XX.sql(文件存放路徑)
     
    示例:mysqldump -h132.72.192.432 -uroot -p test > /home/code/test.sql;

而後輸入密碼便可,注意此命令不須要在mysql終端下執行,只須要linux控制檯下執行便可。

2. 數據庫恢復

若是須要使用備份數據進行恢復,進入mysql命令行,使用以下命令操做:

source /home/code/test.sql
server

mysql -uroot -p密碼 庫名 < test.sqlblog

 

下面爲各類備份的腳本,須要哪個打開#就行token

相關文章
相關標籤/搜索