系统:CentOS Linux release 7.8.2003 (Core)
内核:3.10.0-693.el7.x86_64
1.安装启动MariaDB
安装mariadb 和 mariadb-server
yum install -y mariadb mariadb-server
配置开机自启动并启动服务
systemctl enable --now mariadb
2.配置MariaDB
备份原有配置文件
cp /etc/my.cnf{,.bak}
cp /etc/my.cnf.d/client.cnf{,.bak}
cp /etc/my.cnf.d/mysql-clients.cnf{,.bak}
修改配置文件
cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
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
transaction-isolation=READ-COMMITTED
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
cat /etc/my.cnf.d/mysql-clients.cnf
#
# These groups are read by MariaDB command-line tools
# Use it for options that affect only one utility
#
[mysql]
default-character-set=utf8
[mysql_upgrade]
[mysqladmin]
[mysqlbinlog]
[mysqlcheck]
[mysqldump]
[mysqlimport]
[mysqlshow]
[mysqlslap]
cat /etc/my.cnf.d/client.cnf
#
# These two groups are read by the client library
# Use it for options that affect all clients, but not the server
#
[client]
default-character-set=utf8
# This group is not read by mysql client library,
# If you use the same .cnf file for MySQL and MariaDB,
# use it for MariaDB-only client options
[client-mariadb]
重启mariadb服务
systemctl restart mariadb.service
systemctl status mariadb.service
3.设置密码
mysql_secure_installation
重启mariadb服务
systemctl restart mariadb.service
4.验证部署结果
mysql -u root -p
Enter password:
MariaDB [(none)]> show variables like "%character%";
MariaDB [(none)]> show variables like "%collation%";
5.常用SQL--创建数据库并授权远程访问
MariaDB [(none)]> create database confluence default character set utf8 collate utf8_bin;
MariaDB [(none)]> grant all on confluence.* to "admin"@"%" identified by "admin";
MariaDB[(none)]> grant all on confluence.* to "admin"@"localhost" identified by"admin";
MariaDB [(none)]> flush privileges;
至此,MariaDB部署完毕。