mariadb数据库配置

安装
205  yum install mariadb -y
  206  yum install mariadb-server -y
  207  systemctl restart mariadb
  208  systemctl enable mariadb

初始化

mysql_secure_installation

查看数据库

show databases;

更改密码

MariaDB [(none)]> set password =password(‘linuxprobe‘);

创建账号

MariaDB [(none)]> create user  identified by ‘linuxprobe‘;

添加权限

MariaDB [(none)]> grant select,update,delete,insert on mysql.* to  ;

删除权限

MariaDB [(none)]> revoke select,update,delete,insert on mysql.* to  ;

增删改查

新建数据库

create database linuxprobe;

使用数据库

use linuxprobe;

创建表格

create table mybook(name char(15),price int, pages int);

insert into mybook(name,price,pages) values(‘linuxprobe‘, ‘60‘, ‘400‘);

select * from mybook;

update mybook set price=40;

delete from mybook;

高级查

select * from mybook where name=‘linuxprobe‘;
select name,price from mybook where name=‘linuxprobe‘;
select * from mybook where price>‘50‘;

数据库备份

mysqldump -u root -p linuxprobe >dbbackup.dump

数据库恢复

mysql -u root -p linuxprobe < dbbackup.dump

相关推荐