1. Install mariadb-server
yum install mariadb-server
2. Installation related environment
yum install mariadb-embedded mariadb-libs mariadb-bench mariadb mariadb-sever
3. Install mariadb
yum install mariadb
4. Start mariadb
systemctl start mariadb
5. Set boot up
systemctl enable mariadb
6. Configure the database (mainly to set the password)
mysql_secure_installation
7. Set the encoding
①Add the following content under the /etc/my.cnf file:
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
②Add the following content under the [client] tag of the /etc/my.cnf.d/client.cnf file:
default-character-set=utf8
③Add the following content under the [mysql] tag in the /etc/my.cnf.d/mysql-clients.cnf file:
default-character-set=utf8
④Restart mariadb, the command is as follows:
systemctl restart mariadb
⑤Check mariadb to check the character set, the sentence is as follows:
show variables like "%character%";show variables like "%collation%";
8. Allow remote connection to mariadb database
①Turn off the firewall, the command is as follows:
systemctl stop firewalld
② Modify the host in the user table as follows (execute in sequence):
select host, user from user;
update user set host='%' where host='centos.portal';
flush privileges;
systemctl restart mariadb