MySQL 5.6.38在RedHat 6.5上通过RPM包安装

简介:

一、安装环境

1、操作系统版本:Red Hat Enterprise Linux Server release 6.5 (Santiago)

2、Mysql版本:MySQL-5.6.38-1.el6.x86_64.rpm-bundle.tar


二、安装说明

网上不少资料在使用rpm包安装Mysql 5.6之前,都会先卸载系统自带的mysql-libs,但有的资料是用yum remove mysql,但这样会把依赖mysql-libs的8个包也一同卸载,其中就包括postfix、crontab等软件包,造成了非预期目的的卸载,有的资料就使用rpm -e --nodeps mysql-libs来避免卸载其他依赖mysql-libs的软件包,但是也并非完全正确的做法,Mysql官方提供的Mysql-shared-compat正是替代mysql-libs的rpm包,应先安装此包,再单独卸载mysql-libs,官方说明如下:

f3b003a7cf32a4cdf9cb2a89a1a2817f.png

解压MySQL-5.6.38-1.el6.x86_64.rpm-bundle.tar后,可以看到包含了多个rpm包文件

07036aad7144c4bf1fc42f13a67b9daf.png

网上不少资料都选择了安装Mysql-server、Mysql-client和Mysql-devel三个包,但实际上Mysql-devel的作用是如果需要编译其他mysql客户端例如perl mysql模块或者打算编译C API应用程序,实际上大多数情况下标准安装并不需要安装Mysql-devel,只需要按照Mysql-server和Mysql-client就行,本文就是这样安装。官网的介绍如下:

7dbc5d5b73127fe3cc0d923926c4b9b1.png

d7e8cc8b5a2664defc421a5b9af8939f.png


三、安装过程

1、首先安装一下Mysql-shared-compat,再单独卸载mysql-libs。

16039d52549b128ae129974674943802.png

2、安装mysql-server,根据提示安装完成后的随机密码在/root/.mysql_secret,并且可以运行安全配置向导/usr/bin/mysql_secure_installation,还有配置文件在/usr/my.cnf(按习惯一般拷贝到/etc/my.cnf)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
[root@node01
mysqlrpm] # rpm -ivh MySQL-server-5.6.38-1.el6.x86_64.rpm
warning:
MySQL-server-5.6.38-1.el6.x86_64.rpm: Header V3 DSA /SHA1  Signature, key ID
5072e1f5: NOKEY
Preparing...               
########################################### [100%]
    1:MySQL-server          
########################################### [100%]
warning: user mysql
does not exist - using root
warning: group mysql
does not exist - using root
warning: user mysql
does not exist - using root
warning: group mysql
does not exist - using root
2017-10-28 20:57:24
0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use
--explicit_defaults_for_timestamp server option (see documentation  for  more
details).
2017-10-28 20:57:24
0 [Note] Ignoring --secure- file -priv value as server is running with --bootstrap.
2017-10-28 20:57:24
0 [Note]  /usr/sbin/mysqld  (mysqld 5.6.38) starting as process 8869 ...
2017-10-28 20:57:24
8869 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-10-28 20:57:24
8869 [Note] InnoDB: The InnoDB memory heap is disabled
2017-10-28 20:57:24
8869 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-10-28 20:57:24
8869 [Note] InnoDB: Memory barrier is not used
2017-10-28 20:57:24
8869 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-10-28 20:57:24
8869 [Note] InnoDB: Using Linux native AIO
2017-10-28 20:57:24
8869 [Note] InnoDB: Using CPU crc32 instructions
2017-10-28 20:57:24
8869 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-10-28 20:57:24
8869 [Note] InnoDB: Completed initialization of buffer pool
2017-10-28 20:57:24
8869 [Note] InnoDB: The first specified data  file  . /ibdata1  did not exist: a
new database to be created!
2017-10-28 20:57:24
8869 [Note] InnoDB: Setting  file  . /ibdata1  size to 12 MB
2017-10-28 20:57:24
8869 [Note] InnoDB: Database physically writes the  file  full: wait...
2017-10-28 20:57:25
8869 [Note] InnoDB: Setting log  file  . /ib_logfile101  size to 48 MB
2017-10-28 20:57:26
8869 [Note] InnoDB: Setting log  file  . /ib_logfile1  size to 48 MB
2017-10-28 20:57:27
8869 [Note] InnoDB: Renaming log  file  . /ib_logfile101  to . /ib_logfile0
2017-10-28 20:57:27
8869 [Warning] InnoDB: New log files created, LSN=45781
2017-10-28 20:57:27
8869 [Note] InnoDB: Doublewrite buffer not found: creating new
2017-10-28 20:57:27
8869 [Note] InnoDB: Doublewrite buffer created
2017-10-28 20:57:27
8869 [Note] InnoDB: 128 rollback segment(s) are active.
2017-10-28 20:57:27
8869 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-10-28 20:57:27
8869 [Note] InnoDB: Foreign key constraint system tables created
2017-10-28 20:57:27
8869 [Note] InnoDB: Creating tablespace and datafile system tables.
2017-10-28 20:57:27
8869 [Note] InnoDB: Tablespace and datafile system tables created.
2017-10-28 20:57:27
8869 [Note] InnoDB: Waiting  for  purge to start
2017-10-28 20:57:27
8869 [Note] InnoDB: 5.6.38 started; log sequence number 0
A random root password has been  set . You will  find  it  in  '/root/.mysql_secret' .
2017-10-28 20:57:28
8869 [Note] Binlog end
2017-10-28 20:57:28
8869 [Note] InnoDB: FTS optimize thread exiting.
2017-10-28 20:57:28
8869 [Note] InnoDB: Starting  shutdown ...
2017-10-28 20:57:29
8869 [Note] InnoDB: Shutdown completed; log sequence number 1625977
2017-10-28 20:57:29
0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use
--explicit_defaults_for_timestamp server option (see documentation  for  more
details).
2017-10-28 20:57:29
0 [Note] Ignoring --secure- file -priv value as server is running with
--bootstrap.
2017-10-28 20:57:29
0 [Note]  /usr/sbin/mysqld  (mysqld 5.6.38) starting as process 8891 ...
2017-10-28 20:57:29
8891 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-10-28 20:57:29
8891 [Note] InnoDB: The InnoDB memory heap is disabled
2017-10-28 20:57:29
8891 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-10-28 20:57:29
8891 [Note] InnoDB: Memory barrier is not used
2017-10-28 20:57:29
8891 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-10-28 20:57:29
8891 [Note] InnoDB: Using Linux native AIO
2017-10-28 20:57:29
8891 [Note] InnoDB: Using CPU crc32 instructions
2017-10-28 20:57:29
8891 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-10-28 20:57:29
8891 [Note] InnoDB: Completed initialization of buffer pool
2017-10-28 20:57:29
8891 [Note] InnoDB: Highest supported  file  format  is Barracuda.
2017-10-28 20:57:29
8891 [Note] InnoDB: 128 rollback segment(s) are active.
2017-10-28 20:57:29
8891 [Note] InnoDB: Waiting  for  purge to start
2017-10-28 20:57:29
8891 [Note] InnoDB: 5.6.38 started; log sequence number 1625977
2017-10-28 20:57:29
8891 [Note] Binlog end
2017-10-28 20:57:29
8891 [Note] InnoDB: FTS optimize thread exiting.
2017-10-28 20:57:29
8891 [Note] InnoDB: Starting  shutdown ...
2017-10-28 20:57:31
8891 [Note] InnoDB: Shutdown completed; log sequence number 1625987
 
A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will  find  that password  in  '/root/.mysql_secret' .
  
You must change that password on your first connect,
no other statement but  'SET PASSWORD'  will be accepted.
See the manual  for  the semantics of the  'password expired'  flag.
  
Also, the account  for  the anonymous user has been removed.
  
In addition, you can run:    /usr/bin/mysql_secure_installation
  
which  will also give you the option of removing the  test  database.This is strongly
recommended  for  production servers.
  
See the manual  for  more  instructions.
  
Please report any problems at http: //bugs .mysql.com/
  
The latest information about MySQL is available on the web at http: //www .mysql.com
  
Support MySQL by buying support /licenses  at http: //shop .mysql.com
  
New default config  file  was created as  /usr/my .cnf and will be used by
default by the server when you start it.
You may edit this  file  to change server settings

3、安装Mysql-client

16e559dbea61ab087649fed37703d4cb.png

4、复制my.conf并启动服务

 [root@node01 mysqlrpm]# cp /usr/my.cnf /etc/my.cnf

689adb252f0b4a87256a47d7ea391e91.png

5、RPM包安装后的目录结构如下:

2c373c325cf40ea4d0448f0dcf87b58a.png



四、初始化配置Mysql并登录数据库

1、网上很多资料在RPM安装完Mysql 5.6后还执行了/usr/bin/mysql_install_db进行初始化安装但安全配置向导却没运行,实际上在Mysql 5.6.8开始,用RPM包全新安装时会调用/usr/bin/mysql_install_db并带上随机密码参数,因此并不需要再执行mysql_install_db,反而运行安全配置向导很有必要。官网说明如下:

58cee0d88844ef48c3735509206d2a96.png

2、运行安全配置向导,由于需要输入root密码,因此先查看一下随机生成的密码文件。

1
2
3
[root@node01 ~] # cat /root/.mysql_secret
# The random password set for the root user at Sat Oct 28 20:57:28 2017 (local time):
LyE_R5rVp7p1vLMe

  安全配置向导主要执行以下操作:

  a)是否为root用户设置密码
  b)是否删除匿名账号
  c)是否取消root用户远程登录
  d)是否删除test库和对test库的访问权限
  e)是否刷新授权表使修改生效

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
[root@node01 ~] # cat /root/.mysql_secret
# The random password set for the root user at Sat Oct 28 20:57:28 2017 (local time):
LyE_R5rVp7p1vLMe
 
[root@node01 ~] # /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, 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 MySQL
root user without the proper authorisation.
  
You already have a root password  set , so you can safely answer  'n' .
  
Change the 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 ] n
  ... skipping.
  
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 ] n
  ... skipping.
  
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...


3、登录数据库,确认安装成功完成

18277f3d2e04c42af9a649978a6054f2.png


本文转自Mr大表哥jianlong1990 博客,原文链接: http://blog.51cto.com/jiangjianlong/1978721      如需转载请自行联系原作者



相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。   相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情: https://www.aliyun.com/product/rds/mysql 
相关文章
|
Ubuntu 关系型数据库 MySQL
MySQL源码编译安装
本文详细介绍了MySQL 8.0及8.4版本的源码编译安装全过程,涵盖用户创建、依赖安装、cmake配置、编译优化等步骤,并提供支持多Linux发行版的一键安装脚本,适用于定制化数据库部署需求。
2691 4
MySQL源码编译安装
|
Ubuntu 关系型数据库 MySQL
MySQL二进制包安装
本文详细介绍了在多种Linux系统上通过二进制包安装MySQL 8.0和8.4版本的完整过程,涵盖用户创建、glibc版本匹配、程序解压、环境变量配置、初始化数据库及服务启动等步骤,并提供支持多发行版的一键安装脚本,助力高效部署MySQL环境。
2071 4
MySQL二进制包安装
|
安全 关系型数据库 MySQL
MySQL包安装 -- SUSE系列(离线RPM包安装MySQL)
本文详细介绍在openSUSE系统上通过离线RPM包安装MySQL 8.0和8.4版本的完整步骤,包括下载地址、RPM包解压、GPG密钥导入、使用rpm或zypper命令安装及服务启动验证,涵盖初始密码获取与安全修改方法,适用于无网络环境下的MySQL部署。
1108 3
MySQL包安装 -- SUSE系列(离线RPM包安装MySQL)
|
关系型数据库 MySQL Linux
MySQL包安装 -- SUSE系列(SUSE资源库安装MySQL)
本文介绍了在openSUSE系统上通过SUSE资源库安装MySQL 8.0和8.4版本的完整步骤,包括配置国内镜像源、安装MySQL服务、启动并验证运行状态,以及修改初始密码等操作,适用于希望在SUSE系列系统中快速部署MySQL的用户。
1125 3
MySQL包安装 -- SUSE系列(SUSE资源库安装MySQL)
|
NoSQL 算法 Redis
【Docker】(3)学习Docker中 镜像与容器数据卷、映射关系!手把手带你安装 MySql主从同步 和 Redis三主三从集群!并且进行主从切换与扩容操作,还有分析 哈希分区 等知识点!
Union文件系统(UnionFS)是一种**分层、轻量级并且高性能的文件系统**,它支持对文件系统的修改作为一次提交来一层层的叠加,同时可以将不同目录挂载到同一个虚拟文件系统下(unite several directories into a single virtual filesystem) Union 文件系统是 Docker 镜像的基础。 镜像可以通过分层来进行继承,基于基础镜像(没有父镜像),可以制作各种具体的应用镜像。
1100 6
|
运维 Ubuntu 关系型数据库
MySQL包安装 -- Debian系列(Apt资源库安装MySQL)
本文介绍了在Debian系列系统(如Ubuntu、Debian 11/12)中通过APT仓库安装MySQL 8.0和8.4版本的完整步骤,涵盖添加官方源、配置国内镜像、安装服务及初始化设置,并验证运行状态,适用于各类Linux运维场景。
3089 0
MySQL包安装 -- Debian系列(Apt资源库安装MySQL)
|
Oracle 关系型数据库 MySQL
MySQL包安装 -- RHEL系列(离线RPM包安装MySQL)
本文详细介绍在Rocky、CentOS、AlmaLinux、openEuler等主流Linux系统上,通过离线RPM包安装MySQL 8.0和8.4版本的完整步骤,涵盖下载、依赖处理、rpm/yum安装、服务启动、密码设置等关键环节,适用于多种企业级环境部署需求。
3673 0
MySQL包安装 -- RHEL系列(离线RPM包安装MySQL)
|
存储 关系型数据库 MySQL
Red Hat 安装MySQL 8.0与 Navicat
Red Hat 安装 MySQL 8.0 1、更新软件包列表 在添加 MySQL 存储库后,运行以下命令以更新软件包列表: sudo yum update 2、安装MySQL服务器和客户端 执行以下命令安装MySQL 8.0服务器和客户端软件包: sudo yum install -y mysql-server 3、启动MySQL服务 安装完成后,MySQL 服务器应该已经自动启动。如果没有启动,您可以运行以下命令手动启动服务: sudo systemctl start mysqld 启用 MySQL 服务的开机启动,可以运行以下命令: sudo systemctl enable mysqld
975 1
|
安全 Linux 网络安全
如何在 VM 虚拟机中安装 Red Hat Enterprise Linux 9.3 操作系统保姆级教程(附链接)
如何在 VM 虚拟机中安装 Red Hat Enterprise Linux 9.3 操作系统保姆级教程(附链接)

推荐镜像

更多