Method and Problems of Installing mariadb on centos under mysql

  • 2021-10-25 08:07:08
  • OfStack

Remove the previously installed mariadb

1. Search for MariaDB existing packages using rpm-qa grep mariadb:

If so, use the rpm -e --nodeps mariadb-*全部删除 :


[root@localhost ~]# rpm -qa | grep mariadb
mariadb-server-5.5.52-1.el7.x86_64
mariadb-libs-5.5.52-1.el7.x86_64
[root@localhost ~]# rpm -e mysql-*
 Error: Package not installed  mysql-*

2. Search for MariaDB existing packages using rpm-qa grep mariadb:

If so, use the yum remove mysql mysql-server mysql-libs compat-mysql51 Delete all;

[root@localhost ~]# yum remove mysql mysql-server mysql-libs compat-mysql51
Plug-ins Loaded: fastestmirror, langpacks
Parameter mysql does not match
Parameters mysql-server do not match
Parameters compat-mysql51 do not match
Resolving dependencies
-- > Checking transactions
--- > Package mariadb-libs. x86_64. 1.5. 5.52-1. el7 will be deleted
-- > Processing dependency libmysqlclient. so. 18 () (64bit) required by package perl-DBD-MySQL-4. 023-5.el7.x86_64
-- > Processing dependency libmysqlclient. so. 18 () (64bit) required by package 2: postfix-2. 10.1-6.el7.x86_64
-- > Processing dependency libmysqlclient. so. 18 () (64bit) required by package 1: qt-mysql-4. 8.5-13. el7.x86_64........

Installing mariadb

Installation command:


yum -y install mariadb mariadb-server


Start command:


systemctl start mariadb


Add boot boot


systemctl enable mariadb


Simple configuration


mysql_secure_installation

Enter command line mode


mysql -uroot -p

Problems encountered

Host is not allowed to connect to this MySQL server

MySQL does not allow remote login, so remote login failed. The solution is as follows:

Login the MySQL mysql-u root-p password on a machine with MySQL installed
Execute use mysql;
Execute update user set host = '%' where user = 'root'; This sentence may report an error after execution, so don't worry about it.
Execute FLUSH PRIVILEGES;
After the above four steps, this problem can be solved.
Note: The fourth step is to refresh the permissions related table of MySQL. Don't forget, I didn't execute the fourth step at the first time, and the result was unsuccessful. Finally, I found this reason.

Summarize


Related articles: