本文实例为大家分享CentOS 7.2 Yum安装mysql5.6的方法,供大家参考,具体内容如下
配置CentOS SCLo源
[3] 添加 CentOS SCLo Software collections Repository.[root@linuxprobe~]# yum -y install centos-release-scl-rh centos-release-scl# set [priority=10][root@linuxprobe~]# sed -i -e "s//]$//]/npriority=10/g" /etc/yum.repos.d/CentOS-SCLo-scl.repo[root@linuxprobe~]# sed -i -e "s//]$//]/npriority=10/g" /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo# for another way, change to [enabled=0] and use it only when needed[root@linuxprobe~]# sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/CentOS-SCLo-scl.repo[root@dlp ~]# sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo |
yum安装MySQL
# 安装mysql[root@linuxprobe~]# yum --enablerepo=centos-sclo-rh -y install rh-mysql56-mysql-server# 加载环境变量[root@linuxprobe ~]# scl enable rh-mysql56 bash[root@linuxprobe ~]# mysql -V mysql Ver 14.14 Distrib 5.6.26, for Linux (x86_64) using EditLine wrapper[root@linuxprobe ~]# which mysql /opt/rh/rh-mysql56/root/usr/bin/mysql# 设置mysql开机自启动root@linuxprobe ~]# vi /etc/profile.d/rh-mysql56.sh#!/bin/bashsource /opt/rh/rh-mysql56/enableexport X_SCLS="`scl enable rh-mysql56 'echo $X_SCLS'`" |
[4] Enable MySQL 5.6 and Configure initial settings.[root@linuxprobe ~]# vi /etc/opt/rh/rh-mysql56/my.cnf.d/mysql-server.cnf# add follows within [mysqld] section[mysqld]character-set-server=utf8[root@linuxprobe ~]# systemctl start rh-mysql56-mysqld[root@linuxprobe ~]# systemctl enable rh-mysql56-mysqld[root@linuxprobe ~]# mysql_secure_installationNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!In order to log into MySQL to secure it, we'll need the currentpassword for the root user. If you've just installed MySQL, andyou haven't set the root password yet, the password will be blank,so you should just press enter here.Enter current password for root (enter for none):OK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MySQLroot user without the proper authorisation.# set root passwordSet root password? [Y/n] yNew password:Re-enter new password:Password updated successfully!Reloading privilege tables.. ... Success!By default, a MySQL installation has an anonymous user, allowing anyoneto log into MySQL without having to have a user account created forthem. This is intended only for testing, and to make the installationgo a bit smoother. You should remove them before moving into aproduction environment.# remove anonymous usersRemove anonymous users? [Y/n] y ... Success!Normally, root should only be allowed to connect from 'localhost'. Thisensures that someone cannot guess at the root password from the network.# disallow root login remotelyDisallow root login remotely? [Y/n] y ... Success!By default, MySQL comes with a database named 'test' that anyone canaccess. This is also intended only for testing, and should be removedbefore moving into a production environment.# remove test databaseRemove test database and access to it? [Y/n] - Dropping test database... ... Success! - Removing privileges on test database... ... Success!Reloading the privilege tables will ensure that all changes made so farwill take effect immediately.# reload privilege tablesReload privilege tables now? [Y/n] y ... Success!Cleaning up...All done! If you've completed all of the above steps, your MySQLinstallation should now be secure.Thanks for using MySQL! |