Yum安装 mysql

标签(空格分隔): mysql


1 安装源

参考 https://dev.mysql.com/downloads/repo/yum/

# CentOS 6 / RHEL 6
[root@localhost ~]# yum install https://repo.mysql.com//mysql57-community-release-el6-11.noarch.rpm

# CentOS 7 / RHEL 7
[root@localhost ~]# yum install https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm

2 指定安装版本

查看所有可用版本

[root@localhost ~]#  yum repolist all | grep mysql

使用 mysql5.6

# 关闭当前启用版本
[root@localhost ~]#  yum-config-manager --disable mysql57-community

# 启用 mysql5.6
[root@localhost ~]#  yum-config-manager --enable  mysql56-community

# 检查当前版本
[root@localhost ~]#  yum repolist enabled | grep mysql

3 安装和升级

#  安装
[root@localhost ~]# yum install mysql-community-server

安装的软件有 mysql-community-server,mysql-community-client,mysql-community-common,mysql-community-libs

4 启动 Mysql-Server

启动

# CentOS 6 / RHEL 6
[root@localhost ~]# service mysqld start

# CentOS 7 / RHEL 7
[root@localhost ~]# systemctl start mysqld.service

查看运行状态

# CentOS 6 / RHEL 6
[root@localhost ~]# service mysqld status

# CentOS 7 / RHEL 7
[root@localhost ~]# systemctl status mysqld.service

在第一次启动时,MySQL Server 将会初始化:

  1. 服务器初始化
  2. 在数据目录创建 SSL certificate 和 key 文件
  3. 安装并启动 validate_password plugin
  4. 创建超级用户 'root'@'localhost',密码写入错误日志文件

获得临时密码:

[root@localhost ~]#  grep 'temporary password' /var/log/mysqld.log

使用临时密码登陆后,请立即修改密码

[root@localhost ~]#  mysql -uroot -p

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';

Note

MySQL's validate_password plugin is installed by default. This will
require that passwords contain at least one upper case letter, one
lower case letter, one digit, and one special character, and that the
total password length is at least 8 characters.

5 运行安全程序( MySQL 5.6 )

mysql_secure_installation 执行一些安全化操作,例如设置 root 用户密码,移除匿名用户等。务必在MySQL 5.6安装完成后执行

[root@localhost ~]# mysql_secure_installation

MySQL 5.7 不需要执行这个程序,因为 yum 安装过程中已经完成了这个操作

6 升级

[root@localhost ~]# yum  update mysql-community-server

7 相关目录

参考

A Quick Guide to Using the MySQL Yum Repository

你可能感兴趣的:(Yum安装 mysql)