標籤:yum安裝mysql mysql5.5 mysql5.6 mysql5.7
1、安裝mysql的yum源,這個源包括5.5、5.6、5.7版本:
備忘:如果要專門下載某個版本,可以到http://dev.mysql.com/downloads/repo/yum下載。
[[email protected] ~]# rpm -ivh http://repo.mysql.com/mysql-community-release-el6.rpmRetrieving http://repo.mysql.com/mysql-community-release-el6.rpmwarning: /var/tmp/rpm-tmp.C87LHo: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing... ########################################### [100%] 1:mysql-community-release########################################### [100%]
2、開啟mysql的yum源檔案,如果要安裝mysql哪個版本,選擇後把裡面的enable設定為1。
備忘:或者用yum-config-manager命令方式開啟或關閉。
yum-config-manager --disable mysql55-community
yum-config-manager --enable mysql56-community
yum-config-manager --disable mysql57-community
[[email protected] ~]#vim /etc/yum.repos.d/mysql-community.repo# Enable to use MySQL 5.5[mysql55-community]name=MySQL 5.5 Community Serverbaseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/6/$basearch/enabled=0gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql# Enable to use MySQL 5.6[mysql56-community]name=MySQL 5.6 Community Serverbaseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/enabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql[mysql57-community]name=MySQL 5.7 Community Serverbaseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/enabled=0gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
3、yum安裝mysql組件。
[[email protected] ~]#yum install mysql-community-client mysql-community-devel mysql-community-server php-mysql正在安裝: mysql-community-client x86_64 5.6.38-2.el6 mysql56-community 18 M mysql-community-devel x86_64 5.6.38-2.el6 mysql56-community 3.3 M mysql-community-libs x86_64 5.6.38-2.el6 mysql56-community 1.9 M replacing mysql-libs.x86_64 5.1.73-8.el6_8 mysql-community-libs-compat x86_64 5.6.38-2.el6 mysql56-community 1.6 M replacing mysql-libs.x86_64 5.1.73-8.el6_8 mysql-community-server x86_64 5.6.38-2.el6 mysql56-community 55 M php-mysql x86_64 5.3.3-49.el6 base 86 k為依賴而安裝: mysql-community-common x86_64 5.6.38-2.el6 mysql56-community 308 k numactl x86_64 2.0.9-2.el6 base 74 k php-common x86_64 5.3.3-49.el6 base 530 k php-pdo x86_64 5.3.3-49.el6 base 80 k
4、啟動mysql命令,並設定開機自啟動。
[[email protected] ~]#service mysqld start[[email protected] ~]#chkconfig mysqld on
5、mysql設定root密碼。
[[email protected] ~]#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 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 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 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 database and access to it? [Y/n] y - Dropping test database...ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist ... Failed! Not critical, keep moving... - Removing privileges on test database... ... Success!Reloading the privilege tables will ensure that all changes made so farwill take effect immediately.Reload privilege tables now? [Y/n] y ... Success!All done! If you've completed all of the above steps, your MySQLinstallation should now be secure.Thanks for using MySQL!Cleaning up...
CentOS 6.5通過yum安裝mysql 5.5、5.6、5.7版本