Summary of installing MySQL5.6 under centOS7.5

Preface

One of the "hardest" software to install under Linux is MySQL. It was relatively easy when I installed the centOS6.x version, but it was more troublesome to install when it came to centOS7.x. After 6 hours of installation, the installation was temporarily successful.

installation steps

1. First uninstall the default mysql installation

rpm -qa|grep -i mysql

Uninstalled by default:

rpm -e –nodeps (上面出现的软件)

2. Try to install

rpm -ivh MySQL-server-5.6.24-1.el6.x86_64.rpm
Insert picture description here


It can be seen from the above figure that the installation failed. From the above, you can get the mariadb-libs.
Check whether there are related components of mariadb, and then delete related components of mariadb. As follows:

rpm -qa |grep mariadb
Insert picture description here


Try to delete:

rpm -e mariadb-libs-5.5.56-2.el7.x86_64
Insert picture description here


Of course, when deleting the mariadb-libs-5.5.56-2.el7.x86_64 component, a dependency error is encountered, so the component is forced to be deleted. It is best to use yum to delete the mariadb related components.

yum remove mysql-libs
Insert picture description here

Try to install again

Then I encountered the error "FATAL ERROR: please install the following Perl modules before executing /usr/bin/mysql_install_db" when trying to install MySQL again, as shown below:

Insert picture description here


Solution:

yum install -y perl-Module-Install.noarch

Install again, it prompts that it has been installed, maybe it was installed in the previous step, but when starting the MySQL service, the error "Starting MySQL... ERROR! The server quit without updating PID file (/var/lib/mysql/hadoop102.pid)." is reported. I guess the installation just now was unsuccessful, a "failed product installed".

Insert picture description here


Reinstall and try! There are 3 places to delete when uninstalling:

  • If you do not delete the following, the password will be appended:
Insert picture description here
rm -rf /root/.mysql_secret
  • The following files must be created every time MySQL-server is installed. If the following files are not uninstalled during uninstallation, /usr/my-new.cnf will be created
Insert picture description here


Insert picture description here
rm -rf /usr/my.cnf
如果存在my-new.cnf也同样删除掉:
rm -rf /usr/my-new.cnf
  • If the MySQL-server is successfully installed, the mysql folder will be created under /var/lib/ with related content. If the file is not deleted during uninstallation, the MySQL-server installation again will not succeed. The result is as follows: When the
    last installation of /var/lib/mysql is not deleted, the screenshot when installing MySQL-server: When the
Insert picture description here


last installation of /var/lib/mysql is deleted , the screenshot when installing MySQL-server:

Insert picture description here
rm -rf /var/lib/mysql/

Delete MySQL-server:

rpm -e --nodeps MySQL-server-5.6.24-1.el6.x86_64

Install MySQL-server again

Try to install MySQL-server again:

rpm -ivh MySQL-server-5.6.24-1.el6.x86_64.rpm
Insert picture description here


As can be seen from the above figure, the installation is normal, and try to start the service.

service mysql start
Insert picture description here

Install MySQL-client

rpm -ivh MySQL-client-5.6.24-1.el6.x86_64.rpm 
Insert picture description here


Check the initial password:

Insert picture description here


Login:

Insert picture description here


Set the password:

Insert picture description here


After logging out and logging back in successfully, the installation is successful!
[Other instructions] : It is best to use root installation. Other users have not installed successfully for a long time. Before using centOS6.8 to install mysql5.6 version, using non-root users, the installation can be successful. Now the same version of mysql is installed under centOS7.5, but it cannot be installed under a non-root user. It should be my problem, which has not been solved yet.