系列文章目录
MySQL安装部署中常见问题
前言
本文:主要记录在虚拟机安装MySQL过程中遇到的问题以及解决方案
提示:以下是本篇文章正文内容,下面案例可供参考
一、MySQL的安装
版本:MySQL-client-5.5.48-1.linux2.6.i386.rpm
MySQL-server-5.5.48-1.linux2.6.i386.rpm
下载地址:https://www.mysql.com/
二、安装步骤
1.rpm命令部署MySQL-server
代码如下(示例):rpm -ivh MySQL-server-5.5.48-1.linux2.6.i386.rpm 报错如下
rpm -ivh MySQL-server-5.5.48-1.linux2.6.i386.rpm
警告:MySQL-server-5.5.48-1.linux2.6.i386.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
错误:依赖检测失败:
libaio.so.1 被 MySQL-server-5.5.48-1.linux2.6.i386 需要
libaio.so.1(LIBAIO_0.1) 被 MySQL-server-5.5.48-1.linux2.6.i386 需要
libaio.so.1(LIBAIO_0.4) 被 MySQL-server-5.5.48-1.linux2.6.i386 需要
libc.so.6 被 MySQL-server-5.5.48-1.linux2.6.i386 需要
libc.so.6(GLIBC_2.0) 被 MySQL-server-5.5.48-1.linux2.6.i386 需要
libc.so.6(GLIBC_2.1) 被 MySQL-server-5.5.48-1.linux2.6.i386 需要
libc.so.6(GLIBC_2.1.2) 被 MySQL-server-5.5.48-1.linux2.6.i386 需要
libc.so.6(GLIBC_2.1.3) 被 MySQL-server-5.5.48-1.linux2.6.i386 需要
libc.so.6(GLIBC_2.2) 被 MySQL-server-5.5.48-1.linux2.6.i386 需要
libc.so.6(GLIBC_2.2.3) 被 MySQL-server-5.5.48-1.linux2.6.i386 需要
libc.so.6(GLIBC_2.3) 被 MySQL-server-5.5.48-1.linux2.6.i386 需要
1.1rpm命令报错的原因缺少yum依赖导致
解决方案下载依赖执行:yum install -y libaio.so.1 libc.so.6
yum install -y libaio.so.1 libc.so.6
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误"
1.2.依赖报错原因:当前依赖源不可用
解决方案:
1.21.备份当前的yum源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
[root@localhost yum.repos.d]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
[root@localhost yum.repos.d]# ll
总用量 40
-rw-r--r--. 1 root root 1664 10月 23 2020 CentOS-Base.repo.backup
-rw-r--r--. 1 root root 1309 10月 23 2020 CentOS-CR.repo
-rw-r--r--. 1 root root 649 10月 23 2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 10月 23 2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 10月 23 2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 10月 23 2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 8515 10月 23 2020 CentOS-Vault.repo
-rw-r--r--. 1 root root 616 10月 23 2020 CentOS-x86_64-kernel.repo
1.22.下载新的CentOS-Base.repo 到/etc/yum.repos.d/
本文使用的阿里源
CentOS 7:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
--2024-07-04 17:42:39-- http://mirrors.aliyun.com/repo/Centos-7.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 117.23.49.220, 117.23.49.223, 117.23.49.219
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|117.23.49.220|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2523 (2.5K) [application/octet-stream]
正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”
100%[================================================================================================================>] 2,523 --.-K/s 用时 0.004s
2024-07-04 17:42:39 (684 KB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2523/2523])
1.3.更新依赖源
yum install -y libaio.so.1 libc.so.6
显示如下安装依赖成功
已安装:
glibc.i686 0:2.17-326.el7_9.3 libaio.i686 0:0.3.109-13.el7
作为依赖被安装:
nss-softokn-freebl.i686 0:3.90.0-6.el7_9
作为依赖被升级:
glibc.x86_64 0:2.17-326.el7_9.3 glibc-common.x86_64 0:2.17-326.el7_9.3 glibc-devel.x86_64 0:2.17-326.el7_9.3
glibc-headers.x86_64 0:2.17-326.el7_9.3 nspr.x86_64 0:4.35.0-1.el7_9 nss-softokn-freebl.x86_64 0:3.90.0-6.el7_9
nss-util.x86_64 0:3.90.0-1.el7_9
完毕!
1.3.再次部署MySQL-serverke
可以发下已解决解决上一个问题,但是又有新的问题,新问题是由于系统存在的mariadb-libs-1:5.5.68与部署版本的存在冲突
rpm -ivh MySQL-server-5.5.48-1.linux2.6.i386.rpm
警告:MySQL-server-5.5.48-1.linux2.6.i386.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
file /usr/share/mysql/charsets/README from install of MySQL-server-5.5.48-1.linux2.6.i386 conflicts with file from package mariadb-libs-1:5.5.68-1.el7.x86_64
file /usr/share/mysql/charsets/Index.xml from install of MySQL-server-5.5.48-1.linux2.6.i386 conflicts with file from package mariadb-libs-1:5.5.68-1.el7.x86_64
file /usr/share/mysql/charsets/armscii8.xml from install of MySQL-server-5.5.48-1.linux2.6.i386 conflicts with file from package mariadb-libs-1:5.5.68-1.el7.x86_64
####1.3.1解决方案,查看现有的mariadb
rpm -qa|grep -i mariadb*
[root@localhost opt]# rpm -qa|grep -i mariadb*
mariadb-libs-5.5.68-1.el7.x86_64
mariadb-server-5.5.68-1.el7.x86_64
mariadb-5.5.68-1.el7.x86_64
####1.3.2 删除mariadb,查看现有的mariadb
yum remove mariadb*
[root@localhost opt]# yum remove mariadb*
已加载插件:fastestmirror, langpacks
正在解决依赖关系
--> 正在检查事务
---> 软件包 mariadb.x86_64.1.5.5.68-1.el7 将被 删除
---> 软件包 mariadb-libs.x86_64.1.5.5.68-1.el7 将被 删除
.......
.......
.......
删除:
mariadb.x86_64 1:5.5.68-1.el7 mariadb-libs.x86_64 1:5.5.68-1.el7 mariadb-server.x86_64 1:5.5.68-1.el7
作为依赖被删除:
keepalived.x86_64 0:1.3.5-19.el7 net-snmp.x86_64 1:5.7.2-49.el7 net-snmp-agent-libs.x86_64 1:5.7.2-49.el7 perl-DBD-MySQL.x86_64 0:4.023-6.el7
postfix.x86_64 2:2.10.1-9.el7
完毕!
1.4.部署MySQL-server,部署成功
[root@localhost opt]# rpm -ivh MySQL-server-5.5.48-1.linux2.6.i386.rpm
警告:MySQL-server-5.5.48-1.linux2.6.i386.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:MySQL-server-5.5.48-1.linux2.6 ################################# [100%]
libgcc_s.so.1 must be installed for pthread_cancel to work
libgcc_s.so.1 must be installed for pthread_cancel to work
libgcc_s.so.1 must be installed for pthread_cancel to work
/usr/bin/mysql_install_db: 行 433: 55794 完成 { echo "use mysql;"; cat $create_system_tables
MySQL email archives available at http://lists.mysql.com/.
。。。。。。
。。。。。。
Please check all of the above before submitting a bug report
at http://bugs.mysql.com/
2.rpm命令部署MySQL-client
rpm -ivh MySQL-client-5.5.48-1.linux2.6.i386.rpm
执行报错,缺少依赖
[root@localhost opt]# rpm -ivh MySQL-client-5.5.48-1.linux2.6.i386.rpm
警告:MySQL-client-5.5.48-1.linux2.6.i386.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
错误:依赖检测失败:
libncurses.so.5 被 MySQL-client-5.5.48-1.linux2.6.i386 需要
更新依赖
yum install -y libncurses.so.5
[root@localhost opt]# yum install -y libncurses.so.5
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 ncurses-libs.i686.0.5.9-14.20130511.el7_4 将被 安装
。。。。。。
已安装:
ncurses-libs.i686 0:5.9-14.20130511.el7_4
作为依赖被安装:
libgcc.i686 0:4.8.5-44.el7 libstdc++.i686 0:4.8.5-44.el7
完毕!
再次执行部署:rpm -ivh MySQL-client-5.5.48-1.linux2.6.i386.rpm
部署成功
[root@localhost opt]# rpm -ivh MySQL-client-5.5.48-1.linux2.6.i386.rpm
警告:MySQL-client-5.5.48-1.linux2.6.i386.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:MySQL-client-5.5.48-1.linux2.6 ################################# [100%]
3.启动mysql验证
service mysql start
启动报错
[root@localhost opt]# service mysql start
Starting MySQL.. ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid).
查看日志:cat /var/lib/mysql/localhost.localdomain.err
发现没有初始化数据库导致
240704 18:14:34 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
240704 18:14:34 mysqld_safe mysqld from pid file /var/lib/mysql/localhost.localdomain.pid ended
初始化数据库:/usr/bin/mysql_install_db --user=mysql
[root@localhost opt]# /usr/bin/mysql_install_db --user=mysql
Installing MySQL system tables...
240704 18:21:43 [Note] /usr/sbin/mysqld (mysqld 5.5.48) starting as process 56166 ...
OK
Filling help tables...
240704 18:21:43 [Note] /usr/sbin/mysqld (mysqld 5.5.48) starting as process 56173 ...
OK
。。。。。。
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
。。。。。。
**再次验证:**启动成功
[root@localhost opt]# service mysql start
Starting MySQL… SUCCESS!
总结
提示:这里对文章进行总结:
例如:以上就是今天要讲的内容,本文仅仅简单介绍了MySQL部署过程中可能出现的问题,以及如何解决保障数据库成功启动的。