MariaDB数据库的操作使用与MySQL基本相同。
一、配置
安装MariaDB数据库
[root@linuxidc ~]# yum install mariadb\* -y
启动mariadb服务:
[root@linuxidc ~]# systemctl start mariadb
防火墙添加mysql服务:
[root@linuxidc ~]# firewall-cmd --add-service=mysql --permanent
修改配置文件/etc//my.cnf文件,添加以下编解内容:
character-set-server=utf8
数据库文件存储位置:
datadir=/var/lib/mysql
二、管理数据库
查看数据库:
MariaDB [(none)]> show databases;
查看当前数据库:
MariaDB [(none)]> select database();
查看当前用户:
MariaDB [(none)]> select user();
查看数据库当前的所有属性信息:
MariaDB [(none)]> status
进入数据库:
MariaDB [(none)]> use school;
显示表:
1 MariaDB [school]> show tables;
创建表:
MariaDB [school]> create table teacher(id int,name varchar(10),gender varchar(5) )
查看表结构:
MariaDB [school]> desc teacher;
查询和插入表数据:
1 MariaDB [school]> select * from teacher;
MariaDB [school]> insert into teacher values('1','lisi','male');
清空表内容:
MariaDB [school]> truncate table teacher;
添加列:
MariaDB [school]> alter table teacher add department varchar(20) [first|after column];
删除列:
MariaDB [school]> alter table teacher drop department;
外和内连接:
MariaDB [school]> select * from teacher join student using(id);
MariaDB [school]> select * from teacher inner join student where a.id=b.id;
2015职称计算机考试书PowerPoint2007中 .. 定价:¥45 优惠价:¥42 更多书籍 | |
2015年全国职称计算机考试教材(2007模 .. 定价:¥225 优惠价:¥213 更多书籍 |