您的位置:首页 > 运维架构 > Linux

CentOS 6.5通过yum安装mysql 5.5、5.6、5.7版本

2017-12-24 17:32 966 查看
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...
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  yum 安装 mysql