Installed many times MySQL, but did not well summed up, each time the installation has been forgotten, the next time to re-Google, this summary, their own later also some check.
1. Install the use of the RPM package, before installation to see if the system installed in the old version of the MySQL and MARIADB database, if installed to uninstall first.
The specific command is: rpm-qa| grep mariadb and rpm-qa| grep MySQL, when searching for MySQL will be case-sensitive, so you can change the size of the MySQL under the case, more than a few searches. If it is installed, uninstall it using RPM-E, for example:
[Email protected] ~]# rpm-qa|grep mariadbmariadb-libs-5.5.41-2.el7_0.x86_64[[email protected] ~]# rpm-e Mariadb-libs-5.5.41-2.el7_0.x86_64--nodeps
Then use: Find/-name mysql command search to see if there is still residual files, if any can be deleted directly.
2. Download the new version of the installation package, 5.7 of the URL is: http://dev.mysql.com/downloads/file/?id=462161, I use the RPM installation package, so the download is RPM's full dependency compression package, extension tar,
Download completed after decompression: Tar-xf Mysql-5.7.12-1.el7.x86_64.rpm-bundle.tar, this place note, decompression parameters can not add Zv or will error, this seems to be with the official MySQL tar compression method.
The decompression will release many RPM installation packages, four of which must be installed and have dependencies.
In MySQL minimum mode, you must install the following:
mysql-community-common-5.7.9-1.el7.x86_64.rpm
MYSQL-COMMUNITY-LIBS-5.7.9-1.EL7.X86_64.RPM--(dependent on common)
MYSQL-COMMUNITY-CLIENT-5.7.9-1.EL7.X86_64.RPM--(dependent on Libs)
MYSQL-COMMUNITY-SERVER-5.7.9-1.EL7.X86_64.RPM-(dependent on client, common)
3. After the installation is complete, MySQL is installed, and then the default password for MySQL is generated.
command: mysql_install_db--datadir=/var/lib/mysql // must specify DataDir, ~/.mysql_secret password file will be generated after execution
Or do: mysqld--initialize // new version of this method is recommended, the execution will generate random passwords in/var/log/mysqld.log
Both can generate the initial password, but note the location is different, above the root directory in the. mysql_secret file, the following is in the log file.
4. Modify Permission Group:chown mysql:mysql/var/lib/mysql-R
5. Start the MySQL service: Systemctl start Mysqld.service.
6. According to the method used in 3, see Generate random password, and then log on, command:mysql-u root-p random password
7. Because it is logged in with a random password, the first to change the password, the other command can not be executed, otherwise it will return an error: you   must   reset   your   password   using   ALTER Span class= "Apple-converted-space" >  USER statement before executing This   statemen.
Modify Password command:
1.SET PASSWORD = PASSWORD (' Your new PASSWORD ');
2. ALTER USER ' root ' @ ' localhost ' PASSWORD EXPIRE never;
3. Flush privileges;
Then exit the login again, it can be normal operation.
The above is installed in RPM mode.
The installation process is a reference to a lot of people's blogs, because some are closed, can not be stated here, thank you here.
CentOS installs MySQL in rpm mode