Install MariaDB 10.4 on CentOS7

Reference

Official website Product Documentation Galera cluster

Add REPO file

Use vi or vim to edit the /etc/yum.repos.d/MariaDB.repo file, copy the following content to the file, then save and exit.

            [mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
        

Perform the installation operation and start the service

            yum -y install MariaDB-server MariaDB-client
systemctl enable mariadb
systemctl start mariadb
        

Create user and authorize

After the installation is complete, we can log in to MariaDB directly on this machine and then authorize it. One point that needs special attention for authorization operation is that you cannot replace localhost when you use% to wildcard all addresses, so if we use localhost to access this machine, we must authorize again. After authorization is completed, the permissions must be refreshed, otherwise it will not take effect. For details, please refer to the following example.

            grant all privileges on *.* to 'username'@'%' identified by 'password' with grant option;
grant all privileges on *.* to 'username'@'localhost' identified by 'password' with grant option;
flush privileges;
        

Verification Service

After authorization, we use the new account to log in to MariaDB. If the connection is successful, the configuration is successful. We also need to use other machines to connect to test whether non-local machines can connect to MariaDB. If the connection fails, check whether the firewall is restricted.

            mysql -u username -p password
mysql -h x.x.x.x -u username -p password