1. 程式人生 > >CentOS 6.5通過yum安裝mysql 5.5、5.6、5.7版本

CentOS 6.5通過yum安裝mysql 5.5、5.6、5.7版本

yum安裝mysql mysql5.5 mysql5.6 mysql5.7

1、安裝mysql的yum源,這個源包括5.5、5.6、5.7版本:

備註:如果要專門下載某個版本,可以到http://dev.mysql.com/downloads/repo/yum下載。

[root@agile ~]# rpm -ivh http://repo.mysql.com/mysql-community-release-el6.rpm
Retrieving http://repo.mysql.com/mysql-community-release-el6.rpm
warning: /var/tmp/rpm-tmp.C87LHo: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [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

[root@agile ~]#vim /etc/yum.repos.d/mysql-community.repo
# Enable to use MySQL 5.5
[mysql55-community]
name=MySQL 5.5 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/6/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
# Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql


3、yum安裝mysql組件。

[root@agile ~]#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命令,並設置開機自啟動。

[root@agile ~]#service mysqld start
[root@agile ~]#chkconfig mysqld on


5、mysql設置root密碼。

[root@agile ~]#mysql_secure_installation
NOTE: 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 current
password for the root user.  If you've just installed MySQL, and
you 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 MySQL
root user without the proper authorisation.
Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
 ... Success!
Normally, root should only be allowed to connect from 'localhost'.  This
ensures 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 can
access.  This is also intended only for testing, and should be removed
before 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 far
will take effect immediately.
Reload privilege tables now? [Y/n] y
 ... Success!
All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
Cleaning up...


CentOS 6.5通過yum安裝mysql 5.5、5.6、5.7版本