MariaDB是一个流行的开源关系型数据库管理系统(RDBMS),它是MySQL的一个分支。
安装
bash
apt -y install mariadb-server
bash
vi /etc/mysql/mariadb.conf.d/50-server.cnf
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
bash
systemctl restart mariadb
bash
mysql_secure_installation
Switch to unix_socket authentication [Y/n] n
Change the root password? [Y/n] n
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
启动
bash
mysql

bash
select user,host,password from mysql.user;

bash
show databases;

数据库基本操作
需注意:在mysql下执行命令,需以分号结尾。
bash
#创建数据库test
create database test(即数据库名);
#在数据库test下创建数据表name_table ,包含id和name两个字段,类型分别为int和varchar,id为主键
create table test.name_table (id int, name varchar(50), primary key (id));
#向数据表中插入数据
insert into test.name_table(id, name) values("1", "zhangsan");
#查询
select * from test.name_table;
#退出数据库
exit