Install MySQL with yum in CentOS 7
First, CentOS7 does not support mysql, because you know the charge, so mariadb is integrated internally, and mysql installation will conflict with the mariadb file, so you need to uninstall mariadb first, follow these steps to uninstall mariadb and install mysql.
# List all installed rpm packages
Rpm-qa | grep mariadb
# Uninstall
Rpm e mariadb-libs-5.5.37-1.el7_0.x86_64
Error: dependency check failed:
Libmysqlclient. so.18 () (64bit) is (installed) postfix-2: 2.10.1-6. el7.x86 _ 64 required
Libmysqlclient. so.18 (libmysqlclient_18) (64bit) is required by (installed) postfix-2: 2.10.1-6. el7.x86 _ 64
# Force uninstall because there is no -- nodeps
Rpm-e -- nodeps mariadb-libs-5.5.37-1.el7_0.x86_64
# Install mysql Dependencies
Yum install vim libaio net-tools
Other cases:
1. There is no direct installation package for mysql-server for yum in centos;
MariaDB is a branch of MySQL Community Development and an enhanced alternative;
2. Install MariaDB
Yum-y install mariadb-server mariadb-devel
Systemctl start mariadb
Systemctl enable mariadb
Mysql_secure_installation
Firewall-cmd -- permanent -- add-service mysql
Systemctl restart firewalld. service
Iptables-L-n | grep 3306
By default, mysql does not exist in the yum source of CentOS7. To solve this problem, we need to download the mysql repo source first.
1. Download the mysql repo Source
$ Wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
2. Install the mysql-community-release-el7-5.noarch.rpm package
$ Sudo rpm-ivh mysql-community-release-el7-5.noarch.rpm
After installing this package, you will get the yum repo source for both mysql:/etc/yum. repos. d/mysql-community.repo,/etc/yum. repos. d/mysql-community-source.repo.
3. Install mysql
$ Sudo yum install mysql-server
Follow the steps to install it. However, after the installation is complete, there is no password and you need to reset the password.
4. Reset the password
Before resetting the password, you must first log on
$ Mysql-u root
The following ERROR may be reported during logon: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql. sock '(2), because of/var/lib/mysql access permission issues. The following command changes the owner of/var/lib/mysql to the current user:
$ Sudo chown-R opentracing: opentracing/var/lib/mysql
Then, restart the service:
$ Service mysqld restart
Next, log on to reset the password:
$ Mysql-u root
Mysql> use mysql;
Mysql> update user set password = password ('000000') where user = 'root ';
Mysql> exit;
5. Open Port 3306
$ Sudo vim/etc/sysconfig/iptables
Add the following content:
-A input-p tcp-m state -- state NEW-m tcp -- dport 3306-j ACCEPT
Save and restart the Firewall:
$ Sudo service iptables restart
In this way, other clients can connect to the mysql service.
After MYSQL is started, an ERROR is reported! Solution to The server quit without updating PID file Error
MYSQL Log: Can't find file: './mysql/plugin. frm' (errno: 13-Permission denied)
1. Insufficient permission: chown-R mysql: mysql/home/mysql/data "" chmod-R 755/home/mysql/data
2. selinux of centos7: Enable/etc/selinux/config, change SELINUX = enforcing to SELINUX = disabled, and then save the disk and restart the machine.