Home > Article > System Tutorial > Quickly install MySQL 5.7.17 on CentOS 6.5
This operation is performed on the OpenStack virtual machine 192.168.0.230, and the hostname is: host-172-16-5-7
1. Download the installation packageDownload the latest mysql installation package mysql-5.7.17-Linux-glibc2.5-x86_64.tar.gz from the MySQL official website
download link:
http://dev.mysql.com/downloads/file/?id=467556
Note, be sure to download .tar.gz, do not download the .tar package
Upload the installation package to the /opt directory:
2. Check whether the library file exists and delete it if it exists[root@host-172-16-5-7 ~]# rpm -qa | grep mysql mysql-libs-5.1.73-3.el6_5.x86_64 [root@host-172-16-5-7 ~]# rpm -e mysql-libs-5.1.73-3.el6_5.x86_64 --nodeps /sbin/ldconfig: File /usr/lib64/libpq.so.5.8 is empty, not checked. [root@host-172-16-5-7 ~]# rpm -qa | grep mysql
Please refer to the following documents for the entire installation process:
http://dev.mysql.com/doc/refman/5.7/en/binary-installation.html
3.Mysql depends on the libaio libraryyum search libaio # search for info yum install libaio # install library4. Perform the following steps to install Mysql
groupadd mysql useradd -r -g mysql -s /bin/false mysql cd /usr/local tar -zxvf /opt/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz -C /opt/ ln -s /opt/mysql-5.7.17-linux-glibc2.5-x86_64 mysql cd mysql mkdir mysql-files chmod 750 mysql-files chown -R mysql . chgrp -R mysql . bin/mysqld --initialize --user=mysql
If this step reports an error as follows:
[ERROR] --initialize specified but the data directory has files in it. Aborting.
solution:
rm -rf /var/lib/mysql/
Re-execute the above command, and a temporary password is generated:
2017-01-03T09:12:33.748807Z 1 [Note] A temporary password is generated for root@localhost: =*-gFoje>1Pr
Executing this step should generate a data directory. If it is not generated, it must be because there is already installed mysql in the system. First uninstall it according to step 2, and then execute it again
bin/mysqld --initialize --user=mysql bin/mysql_ssl_rsa_setup chown -R root . chown -R mysql data mysql-files bin/mysqld_safe --user=mysql &
The following step is optional
cp support-files/mysql.server /etc/init.d/mysqld5. Configuration after installation
Modify /usr/local/mysql/support-files/my-default.cnf
basedir = /usr/local/mysql datadir = /usr/local/mysql/data port = 3306
After modification, copy a copy to the /etc/ directory and rename it to my.cnf
cp my-default.cnf /etc/my.cnf
Add mysql environment variable
vim /etc/profile export MYSQL_HOME=/usr/local/mysql export PATH=$MYSQL_HOME/bin:$PATH source /etc/profile6.Start mysql
service mysqld start
Start successfully:
[root@ambari support-files]# service mysqld start Starting MySQL.Logging to '/usr/local/mysql/data/ambari.err'. . [ OK ] [root@ambari support-files]# service mysqld status MySQL running (8010) [ OK ]
When executing this step, the startup may not be successful. The error message is as follows:
MySQL: Starting MySQL….. ERROR! The server quit without updating PID file
You can refer to the following link to solve the problem:
https://icesquare.com/wordpress/mysql-starting-mysql-error-the-server-quit-without-updating-pid-file/
If you don’t want to bother, you can directly restart the machine to solve the problem
At this point, mysql has been installed and started successfully.
7. Change root password:use
mysql -uroot -p
When logging in, enter the root password recorded previously, and it prompts that the password is incorrect. We have no choice but to change the root password ourselves
Specific steps are as follows:
step1:
vim /etc/my.cnf
Add a line skip-grant-tables under [mysqld]
step2:
After service mysqld restart, you can directly use mysql to enter
mysql> update mysql.user set authentication_string=password('root') where user='root' and Host = 'localhost'; mysql> flush privileges; mysql> quit;
step3:
Restore the /etc/my.cnf file and restart mysql:service mysqld restart. At this time, you can use mysql -u root -p'root' to enter
step4:
After entering sql, change the password once through the following command, otherwise you cannot perform other operations:
mysql> SET PASSWORD = PASSWORD('mysql');
step5:
Execute show databases on the sql console; the results are as follows:
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec)
Attachment: Reference document, thank you for sharing. It is precisely because of your experience that I can quickly solve various problems encountered during the installation process:
http://www.cnblogs.com/tuhooo/p/5189236.html
https://icesquare.com/wordpress/mysql-starting-mysql-error-the-server-quit-without-updating-pid-file/
The above is the detailed content of Quickly install MySQL 5.7.17 on CentOS 6.5. For more information, please follow other related articles on the PHP Chinese website!