MariaDB數(shù)據(jù)庫(kù)管理系統(tǒng)是MySQL的一個(gè)分支魄藕,主要由開源社區(qū)在維護(hù),采用GPL授權(quán)許可 MariaDB的目的是完全兼容MySQL撵术,包括API和命令行背率,使之能輕松成為MySQL的代替品。在存儲(chǔ)引擎方面嫩与,使用XtraDB(英語(yǔ):XtraDB)來(lái)代替MySQL的InnoDB寝姿。
安裝步驟:
1,使用yum命令安裝mariaDB
yum -y install mariadb mariadb-server
2划滋,啟動(dòng)mariaDB
systemctl start mariadb
3饵筑,設(shè)置開機(jī)啟動(dòng)
systemctl enable mariadb
4,進(jìn)行簡(jiǎn)單相關(guān)配置
mysql_secure_installation
5处坪,配置mariaDB字符集
(1)vi /etc/my.cnf
在[mysqld]標(biāo)簽下添加
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
(2)vi /etc/my.cnf.d/client.cnf
在[client]中添加
default-character-set=utf8
(3)vi /etc/my.cnf.d/mysql-clients.cnf
在[mysql]中添加
default-character-set=utf8
(4)全部配置完成根资,重啟mariadb
systemctl restart mariadb
6,登錄mariaDB同窘,查看MariaDB字符集
mysql -uroot -p
show variables like "%character%";
show variables like "%collation%";
7玄帕,添加用戶,設(shè)置權(quán)限
創(chuàng)建用戶命令
mysql>create user sa@localhost identified by 'password';
直接創(chuàng)建用戶并授權(quán)的命令
mysql>grant all on *.* to sa@'%'indentified by 'password';
授予外網(wǎng)登陸權(quán)限
mysql>grant all privileges on *.* to sa@'%' identified by 'password';
授予權(quán)限并且可以授權(quán)
mysql>grant all privileges on *.* to sa@'%' identified by 'password' with grant option;
簡(jiǎn)單的用戶和權(quán)限配置基本就這樣了想邦。
其中只授予部分權(quán)限把其中all privileges或者all改為
select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file其中一部分裤纹。
8,數(shù)據(jù)庫(kù)基礎(chǔ)操作:增刪查改丧没,操作表鹰椒。
(1)用root賬號(hào)登錄mariadb锡移,創(chuàng)建用戶luchiwen,并授予數(shù)據(jù)庫(kù)操作權(quán)限吹零。
mysql -uroot -p123
create user luchiwen@localhost identified by '1234';
grant all on *.* to luchiwen@'localhost';??
(2)同luchiwen賬號(hào)登錄mariadb罩抗,查看數(shù)據(jù)庫(kù)。
mysql -uluchiwen -p1234
show databases;
(3)創(chuàng)建數(shù)據(jù)庫(kù)進(jìn)行測(cè)試
CREATE DATABASE school;
show databases;
(4)建立一個(gè)表
使用school這個(gè)數(shù)據(jù)庫(kù)
use school;
CREATE TABLE student(
name VARCHAR(10) NOT NULL,
number VARCHAR(11) NOT NULL,
age INT NOT NULL,
PRIMARY KEY (number)
);
查看正在使用的數(shù)據(jù)庫(kù)中的表
show tables;
(5)插入數(shù)據(jù)
Insert into student values(‘lcw’,’666,15);
(6)查詢數(shù)據(jù)
Select * from student;