mariadb資料庫簡單操作

來源:互聯網
上載者:User

標籤:進入   base   char   inux   mysqld   roo   dump   sql資料庫   linu   

2.查詢

show databases;        ##顯示資料庫
use mysql;        ##進入mysql資料庫
show tables;        ##顯示當前庫中表的名稱
select * from user;    ##查詢user表中的所有內容

desc user;        ##查詢user表的結構

 

3.資料庫以及表的建立

create database westos;            ##建立westos資料庫
create table linux(            ##建立表linux
username varchar(15) not null,        ##username欄位,字元最大長度為15,且不為空白
password varchar(15) not null
);
insert into linux values (‘user1‘,‘passwd1‘);    ##給linux表中添加資料

insert into linux values (‘user1‘,password(‘passwd1‘));    ##給linux表中添加資料,且密碼加密

 

4.更新資料庫資訊

update linux set password=password(‘passwd2‘) where username=‘user1‘;    ##更新名字是user1的密碼

update linux set password=password(‘123‘) where (username=‘user1‘ or username=‘user2‘);    ##更新user1,user2密碼

 

 

5.刪除資料庫

delete from linux where username=‘user1‘;    ##從linux表中刪除user1使用者
drop table linux;                ##刪除linux表
drop database westos;                ##刪除westos資料庫

6.資料庫的備份

mysqldump -u root -pwestos --all-database    ##備份所有表中的所有資料
mysqldump -u root -pwestos --all-database --no-date    ##備份所有表,但不備份資料
mysqldump -u root -pwestos westos         ##備份westos資料庫
mysqldump -u root -pwestos westos > /mnt/westos.sql    ##備份westos庫,並將資料儲存到westos.sql檔案中
mysqldump -u root -pwestos westos linux > /mnt/linux.sql    ##備份westos資料庫中的linux表
mysql -uroot -pwestos -e "create database westos;"        ##還原資料時,應先建立相應的westos庫

mysql -uroot -pwestos westos < /mnt/westos.sql            ##將資料匯入westos庫

mariadb資料庫簡單操作

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.