The result of tag: (1 results)

如何用yum安装MySQL5.5

by LauCyun Mar 19,2016 21:18:45 8,287 views

使用yum安装的MySQL版本是MySQL 5.1,但是我们想要安装MySQL 5.5,怎么办呢?方法有以下几种:

  • 下载MySQL 5.5源码,手动编译安装(非常复杂且麻烦);
  • 手工下载rpm包安装(这里面有的依赖包还需要自己装,并不是一下子就能搞定的);
  • yum安装。

那下面讲一下如何使用yum安装MySQL 5.5。

1 安装软件源

需要两个软件源:epelremi

epel软件源:https://mirrors.aliyun.com/epel

## CentOS 6 and Red Hat (RHEL) 6 ##
rpm -Uvh https://mirrors.aliyun.com/epel/epel-release-latest-6.noarch.rpm

## CentOS 7 and Red Hat (RHEL) 7 ##
rpm -Uvh https://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm

remi软件源:http://rpms.remirepo.net/

## CentOS 6 and Red Hat (RHEL) 6 ##
rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-6.rpm

## CentOS 7 and Red Hat (RHEL) 7 ##
rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm

2 查看MySQL版本号

yum --enablerepo=remi,remi-test list mysql mysql-server  

输出信息:

Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: mirrors.huaweicloud.com
 * epel: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.huaweicloud.com
 * remi: mirrors.tuna.tsinghua.edu.cn
 * remi-safe: mirrors.tuna.tsinghua.edu.cn
 * remi-test: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.huaweicloud.com
Available Packages
mysql.x86_64                              5.5.48-1.el6.remi                        @remi
mysql-server.x86_64                       5.5.48-1.el6.remi                        @remi

3 安装MySQL

yum --enablerepo=remi,remi-test install mysql mysql-server

4 MySQL安全设置

  • 设置(修改)root密码
  • 删除匿名用户
  • 禁用root远程登录
  • 删除测试数据库test
  • 重载权限表

要启用MySQL安全设置请输入以下命令:

/usr/bin/mysql_secure_installation

输出:

[root@laucyun /]# /usr/bin/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                      # 设置MySQL管理员root密码
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                 # 移除匿名用户,选择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           # 移除管理员远程访问权限,选择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  # 移除test测试数据库,选择Y
 - Dropping test database...
 ... Success!
 - 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            # 刷新数据库权限,选择Y 
 ... Success!

Cleaning up...



All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

如果您不想启动MySQL安全设置命令,但至少也得修改一下root用户密码:

mysqladmin -u root password [your_password_here]
## 栗子 ##
mysqladmin -u root password 123qwe

Oky,我们已经成功用yum安装了MySQL 5.5。

最后,分享在CentOS 6中MySQL 5.5的Dockerfile:http://github.laucyun.com/Dockerfiles/tree/master/CentOS6/mysql55

 

修改日志

Mar 19,2016:撰写

August 2,2018:将epel的软件源修改为https://mirrors.aliyun.com/epel,remi的软件源修改为http://rpms.remirepo.net

...

Tags Read More