基础环境
1.OS版本centos7
2.mariadb-5.5.56
[root@node1 ~]# yum install -y mariadb
已加载插件:fastestmirror
base | 3.6 kB 00:00:00
elasticsearch-2.x | 2.9 kB 00:00:04
epel/x86_64/metalink | 4.8 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 3.4 kB 00:00:00
logstash-2.1 | 951 B 00:00:00
updates | 3.4 kB 00:00:00
(1/6): base/7/x86_64/group_gz | 166 kB 00:00:00
(2/6): extras/7/x86_64/primary_db | 143 kB 00:00:00
(3/6): epel/x86_64/group_gz | 88 kB 00:00:00
(4/6): updates/7/x86_64/primary_db | 1.2 MB 00:00:00
(5/6): epel/x86_64/updateinfo | 926 kB 00:00:13
(6/6): epel/x86_64/primary_db | 6.4 MB 00:00:44
Determining fastest mirrors
以上使用yum安装mariadb数据库
systemctl start mariadb
启动数据库
systemctl status mariadb
查看数据库状态
如启动失败:请查看相关log
默认情况下使用mysql命令直接进入命令行
SHOW DATABASES;
查看数据库
use test;
CREATE TABLE user
(id
int(10) unsigned NOT NULL auto_increment, sex
tinyint(1) default 1 COMMENT '性别:0女;1男;2保密',age
int(3) default 1 COMMENT '年龄',province
char(254) default NULL COMMENT '所在省份',
PRIMARY KEY (id
)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
INSERT INTO user(sex,age,province) VALUES
('1','22','北京'),
('0','25','广东'),
('0','56','天津'),
('1','14','北京'),
('0','36','广东'),
('1','68','湖南'),
('1','45','北京'),
('1','17','河北'),
('2','33','天津'),
('1','27','湖南'),
('1','29','北京'),
('2','70','广东'),
('0','24','北京')
以上为测试用表。
转载于:https://blog.51cto.com/imork/2119143