MARIADB Database Simple operation

Source: Internet
Author: User
Tags create database

2. Enquiry

show databases; # #显示数据库
Use MySQL; # #进入mysql数据库
Show tables; # #显示当前库中表的名称
select * from user; # #查询user表中的所有内容

DESC user; # #查询user表的结构

3. Establishment of databases and tables

Create Database Westos; # #创建westos数据库
CREATE TABLE Linux (# #创建表linux
Username varchar (15) NOT NULL, # #username字段, maximum character length is not empty
Password varchar () NOT NULL
);
INSERT into Linux values (' User1 ', ' passwd1 '); # #给linux表中添加数据

INSERT into Linux values (' User1 ', password (' passwd1 ')); # #给linux表中添加数据, and password encryption

4. Update database Information

Update Linux set Password=password (' Passwd2 ') where username= ' User1 '; # #更新名字是user1的密码

Update Linux set Password=password (' 123 ') where (username= ' user1 ' or username= ' user2 '); # #更新user1, user2 password

5. Deleting a database

Delete from Linux where username= ' user1 '; # #从linux表中删除user1用户
drop table Linux; # #删除linux表
Drop database Westos; # #删除westos数据库

6. Backup of the database

Mysqldump-u Root-pwestos--all-database # #备份所有表中的所有数据
Mysqldump-u root-pwestos--all-database--no-date # #备份所有表 but does not back up data
Mysqldump-u Root-pwestos Westos # #备份westos数据库
Mysqldump-u Root-pwestos westos >/mnt/westos.sql # #备份westos库 and save the data to a Westos.sql file
Mysqldump-u root-pwestos Westos linux >/mnt/linux.sql # #备份westos数据库中的linux表
MYSQL-UROOT-PWESTOS-E "CREATE database Westos;" # #还原数据时, the corresponding Westos library should be established first

Mysql-uroot-pwestos Westos </mnt/westos.sql # #将数据导入westos库

MARIADB Database Simple operation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.