mysql 5.5 64位 linux_64位linux下rpm安装mysql的5.5.55版本所遇到的坑

在Linux 64位环境中使用rpm方式安装MySQL 5.5.55时,遭遇了一系列问题,包括依赖包缺失、文件找不到、启动错误等。首先从非官方网站下载了多个rpm包,然后在安装过程中遇到了libcrypto.so.6和libssl.so.6等依赖问题,通过下载并安装相应包解决。在执行mysql_install_db时,又发现libaio.so.1文件缺失,通过建立软链接解决问题。最终,数据库初始化成功,但在启动mysqld服务时失败。通过查找错误日志,发现需要修改配置文件中的socket路径和数据目录,并给予新数据目录相应的权限,才能成功启动MySQL服务。
摘要由CSDN通过智能技术生成

昨天同事开了个阿里云环境,让我帮他安装mysql数据库,本想着很简单的一件事,结果还是折腾了一番。坑很多,一路趟过,一个接一个,只能硬着头皮冲。

首先是下载压缩包,因为采用了rpm安装方式,所以下载的是rpm包。rpm需要至少3个包,一个客户端,一个服务端,还有一个开发包,这3个是必须的。另外还有好几个相关的包,我一并都下了,附上下载地址:

https://centos.pkgs.org/5/atomic-x86_64/mysql-5.5.55-1659.el5.art.x86_64.rpm.html

https://centos.pkgs.org/5/atomic-x86_64/mysql-server-5.5.55-1659.el5.art.x86_64.rpm.html

https://centos.pkgs.org/5/atomic-x86_64/mysql-devel-5.5.55-1659.el5.art.x86_64.rpm.html

https://centos.pkgs.org/5/atomic-x86_64/mysql-libs-5.5.55-1659.el5.art.x86_64.rpm.html

https://centos.pkgs.org/5/atomic-x86_64/mysql-embedded-5.5.55-1659.el5.art.x86_64.rpm.html

https://centos.pkgs.org/5/atomic-x86_64/mysql-embedded-devel-5.5.55-1659.el5.art.x86_64.rpm.html

https://centos.pkgs.org/5/atomic-x86_64/mysql-test-5.5.55-1659.el5.art.x86_64.rpm.html

第一步就进坑,这第一个坑引起了后面所有的坑。这里下载版本是比较老的,而且是从centos.pkgs.org上下载的,而不是从mysql官网。虽然包是没啥区别,但这里同一版本号的包竟然不放在一起,而是按客户端、服务端这样去分类的。这让我在后面碰到各种奇葩问题的时候,一度怀疑自己是不是下对了包、漏下了包,所以才把所有5.5.55相关的包都下了。不怕一万,就怕万一啊。建议还从mysql官网下包,官网会弹出一个下拉框给你选版本,清晰明了。这里介绍怎么从官网安装Windows版的mysql:64位windows下mysql安装。

另一个问题就是这里下的包对应的是centos操作系统,而且版本号是5。下包前要确认自己linux的操作系统,可以在linux用该命令看

[root@izwz932ypmamm80m434qqyz lib]# cat /proc/version

Linux version3.10.0-514.26.2.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) ) #1 SMP Tue Jul 4 15:04:05 UTC 2017

centOS也算是RedHat,所以下一步就是安装了,把上面的rpm包都通过ftp上传到usr下新建的mysql目录里,重复执行解压命令,开始报错了:

[root@izwz932ypmamm80m434qqyz mysql]# rmp -ivh mysql-server-5.5.55-1659.el5.art.x86_64.rpm-bash: rmp: command not found

[root@izwz932ypmamm80m434qqyz mysql]# rpm-ivh mysql-server-5.5.55-1659.el5.art.x86_64.rpm

warning: mysql-server-5.5.55-1659.el5.art.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID 4520afa9: NOKEY

error: Failed dependencies:

libcrypto.so.6()(64bit) is needed by mysql-server-5.5.55-1659.el5.art.x86_64

libssl.so.6()(64bit) is needed by mysql-server-5.5.55-1659.el5.art.x86_64

perl(DBI)is needed by mysql-server-5.5.55-1659.el5.art.x86_64

perl(Data::Dumper)is needed by mysql-server-5.5.55-1659.el5.art.x86_64

perl-DBD-MySQL is needed by mysql-server-5.5.55-1659.el5.art.x86_64

perl-DBI is needed by mysql-server-5.5.55-1659.el5.art.x86_64

这个错误是依赖分析失败引起的,可以通过增加命令参数忽略依赖分析,直接执行解压:

[root@izwz932ypmamm80m434qqyz mysql]# rpm -ivh mysql-server-5.5.55-1659.el5.art.x86_64.rpm --nodeps --force

解压结束后按道理mysql已经装好了,此时在/usr/share/mysql目录下会给出几个示例配置文件,这里选择my-medium.cnf,把它复制到下/etc/my.cnf作为启动配置文件,执行/usr/bin目录里的mysql_install_db脚本就初始化启动数据库,继续报错:

[root@izwz932ypmamm80m434qqyz ~]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf

cp: overwrite ‘/etc/my.cnf’?y

[root@izwz932ypmamm80m434qqyz~]# /usr/bin/mysql_install_db

Installing MySQL system tables.../usr/libexec/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared objectfile: No such file or directory

Installation of system tables failed! Examine the logs in

/var/lib/mysql formore information.

You cantryto start the mysqld daemon with:

shell> /usr/libexec/mysqld --skip-grant &and use the command line tool/usr/bin/mysql

to connect to the mysql database and look at the grant tables:

shell> /usr/bin/mysql -u root mysql

mysql>show tables

Try'mysqld --help' if you have problems with paths. Using --log

gives you a login /var/lib/mysql that may be helpful.

Please consult the MySQL manual section'Problems running mysql_install_db', and the manual section that

describes problems on your OS. Another information source are the

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/

这里提示找不到libaio.so.1,好吧,那么就下载对应的包吧。既然已经上了centos.pkgs.org的贼船,只好一路走到黑了。还是找了centOS5的rpm包:

https://centos.pkgs.org/5/centos-x86_64/libaio-0.3.106-5.x86_64.rpm.html

执行安装命令rpm -ivh(这次无需加参数--nodeps --force了)后,发现libaio.so.1已经出现在/usr/lib64目录下了,只不过发现其实该文件也就是个软链接而已:

[root@izwz932ypmamm80m434qqyz mysql]# cd /usr/lib64

[root@izwz932ypmamm80m434qqyz lib64]# ll

total59724drwxr-xr-x. 3 root root 4096 Aug 18 11:51 alsa-lib

drwxr-xr-x. 2 root root 4096 Aug 18 11:57audit

lrwxrwxrwx.1 root root 36 Aug 18 11:51 cracklib_dict.hwm -> ../../usr/share/cracklib/pw_dict.hwm

lrwxrwxrwx.1 root root 36 Aug 18 11:51 cracklib_dict.pwd -> ../../usr/share/cracklib/pw_dict.pwd

lrwxrwxrwx.1 root root 36 Aug 18 11:51 cracklib_dict.pwi -> ../../usr/share/cracklib/pw_dict.pwi-rw-r--r-- 1 root root 1888 Jul 17 21:08crt1.o-rw-r--r-- 1 root root 1248 Jul 17 21:08crti.o-rw-r--r-- 1 root root 968 Jul 17 21:08crtn.o

drwxr-xr-x. 2 root root 4096 Aug 18 11:51 dbus-1drwxr-xr-x. 2 root root 4096 Aug 18 11:51ebtables

drwxr-xr-x. 2 root root 4096 Aug 18 11:51elfutils

drwxr-xr-x. 2 root root 4096 Aug 18 11:57fipscheck

dr-xr-xr-x. 2 root root 4096 Nov 5 2016games

drwxr-xr-x. 2 root root 12288 Aug 18 11:57gconv-rw-r--r-- 1 root root 2456 Jul 17 21:08gcrt1.o

drwxr-xr-x. 2 root root 4096 Aug 18 11:51gettext

drwxr-xr-x. 3 root root 4096 Aug 18 11:51gio

drwxr-xr-x. 2 root root 4096 Aug 18 11:57 girepository-1.0drwxr-xr-x. 3 root root 4096 Dec 7 2016krb5-rwxr-xr-x 1 root root 159640 Jul 17 21:36 ld-2.17.so

lrwxrwxrwx1 root root 10 Aug 18 11:57 ld-linux-x86-64.so.2 -> ld-2.17.so

lrwxrwxrwx1 root root 20 Aug 18 11:59 ld-lsb-x86-64.so.3 -> ld-linux-x86-64.so.2lrwxrwxrwx.1 root root 15 Aug 18 11:51 libacl.so.1 -> libacl.so.1.1.0

-rwxr-xr-x. 1 root root 37056 Jun 10 2014 libacl.so.1.1.0lrwxrwxrwx1 root root 15 Dec 19 10:39 libaio.so.1 -> libaio.so.1.0.1

重新执行/usr/bin/mysql_install_db,又报错了,这次是找不到libcrypto.so.6文件,我先退出到根目录搜了一下

find -name 'libcrypto.so.6'

发现该文件是存在的,只不过是在/usr/local/aegis/PythonLoader/third_party目录下。直接建立软链接

cd usr/lib64

ln-s /usr/local/aegis/PythonLoader/third_party/libcrypto.so.6 libcrypto.so.6

其他找不到文件的情况处理方式同上。现在文件都有了,初始化数据库终于成功了:

[root@izwz932ypmamm80m434qqyz lib64]# /usr/bin/mysql_install_db

Installing MySQL system tables...171219 10:52:13 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.171219 10:52:13 [Note] /usr/libexec/mysqld (mysqld 5.5.55-log) starting as process 10439...

OK

Filling help tables...171219 10:52:14 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.171219 10:52:14 [Note] /usr/libexec/mysqld (mysqld 5.5.55-log) starting as process 10446...

OK

To start mysqld at boot time you have to copy

support-files/mysql.server to the right place foryour system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER!Todoso, start the server, then issue the following commands:/usr/bin/mysqladmin -u root password 'new-password'

/usr/bin/mysqladmin -u root -h izwz932ypmamm80m434qqyz password 'new-password'Alternatively you can run:/usr/bin/mysql_secure_installation

which will also give you the option of removing the test

databases and anonymous user created bydefault. This isstrongly recommendedforproduction servers.

See the manualformore instructions.

You can start the MySQL daemon with:

cd/usr ; /usr/bin/mysqld_safe &You can test the MySQL daemon with mysql-test-run.pl

cd/usr/mysql-test ; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/

好了,既然数据库已经初始化了,改启动mysql了,问题来了:

[root@izwz932ypmamm80m434qqyz /]# service mysqld startStarting mysqld (via systemctl): Jobfor mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" fordetails.

[root@izwz932ypmamm80m434qqyz/]# systemctl status mysqld.service● mysqld.service-LSB: start and stop MySQL server

Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled)

Active: failed (Result: exit-code) since Tue 2017-12-19 11:49:54CST; 54s ago

Docs: man:systemd-sysv-generator(8)

Process:11250 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=1/FAILURE)

Dec19 11:49:52 izwz932ypmamm80m434qqyz mysqld[11250]: You can test the MySQL...

Dec19 11:49:52 izwz932ypmamm80m434qqyz mysqld[11250]: cd /usr/mysql-test ; p...

Dec19 11:49:52 izwz932ypmamm80m434qqyz mysqld[11250]: Please report any prob...

Dec19 11:49:52 izwz932ypmamm80m434qqyz mysqld[11250]: [ OK ]

Dec19 11:49:54 izwz932ypmamm80m434qqyz mysqld[11250]: MySQL Daemon failed to...

Dec19 11:49:54 izwz932ypmamm80m434qqyz mysqld[11250]: Starting mysqld: [FAI...

Dec19 11:49:54 izwz932ypmamm80m434qqyz systemd[1]: mysqld.service: control p...

Dec19 11:49:54 izwz932ypmamm80m434qqyz systemd[1]: Failed to start LSB: star...

Dec19 11:49:54 izwz932ypmamm80m434qqyz systemd[1]: Unit mysqld.service enter...

Dec19 11:49:54 izwz932ypmamm80m434qqyz systemd[1]: mysqld.service failed.

Hint: Some lines were ellipsized, use-l to show infull.

[root@izwz932ypmamm80m434qqyz/]# journalctl -xeDec19 11:49:52 izwz932ypmamm80m434qqyz mysqld[11250]: /usr/bin/mysqladmin -u root password 'new-password'Dec19 11:49:52 izwz932ypmamm80m434qqyz mysqld[11250]: /usr/bin/mysqladmin -u root -h izwz932ypmamm80m434qqyz password 'new-password'Dec19 11:49:52 izwz932ypmamm80m434qqyz mysqld[11250]: Alternatively you can run:

Dec19 11:49:52 izwz932ypmamm80m434qqyz mysqld[11250]: /usr/bin/mysql_secure_installation

Dec19 11:49:52 izwz932ypmamm80m434qqyz mysqld[11250]: which will also give you the option of removing the test

Dec19 11:49:52 izwz932ypmamm80m434qqyz mysqld[11250]: databases and anonymous user created by default. This isDec19 11:49:52 izwz932ypmamm80m434qqyz mysqld[11250]: strongly recommended forproduction servers.

Dec19 11:49:52 izwz932ypmamm80m434qqyz mysqld[11250]: See the manual formore instructions.

Dec19 11:49:52 izwz932ypmamm80m434qqyz mysqld[11250]: You can start the MySQL daemon with:

Dec19 11:49:52 izwz932ypmamm80m434qqyz mysqld[11250]: cd /usr ; /usr/bin/mysqld_safe &Dec19 11:49:52 izwz932ypmamm80m434qqyz mysqld[11250]: You can test the MySQL daemon with mysql-test-run.pl

Dec19 11:49:52 izwz932ypmamm80m434qqyz mysqld[11250]: cd /usr/mysql-test ; perl mysql-test-run.pl

Dec19 11:49:52 izwz932ypmamm80m434qqyz mysqld[11250]: Please report any problems at http://bugs.mysql.com/

Dec 19 11:49:52 izwz932ypmamm80m434qqyz mysqld[11250]: [ OK ]

Dec19 11:49:54 izwz932ypmamm80m434qqyz mysqld[11250]: MySQL Daemon failed to start.

Dec19 11:49:54 izwz932ypmamm80m434qqyz mysqld[11250]: Starting mysqld: [FAILED]

Dec19 11:49:54 izwz932ypmamm80m434qqyz systemd[1]: mysqld.service: control process exited, code=exited status=1Dec19 11:49:54 izwz932ypmamm80m434qqyz systemd[1]: Failed to start LSB: start and stop MySQL server.--Subject: Unit mysqld.service has failed-- Defined-By: systemd-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

--

--Unit mysqld.service has failed.--

-- The result isfailed.

Dec19 11:49:54 izwz932ypmamm80m434qqyz systemd[1]: Unit mysqld.service entered failed state.

Dec19 11:49:54 izwz932ypmamm80m434qqyz systemd[1]: mysqld.service failed.

Dec19 11:49:54 izwz932ypmamm80m434qqyz polkitd[462]: Unregistered Authentication Agent for unix-process:11244:61448081 (system bus name :1.2579, object path /org/freed

Dec19 11:50:01 izwz932ypmamm80m434qqyz systemd[1]: Started Session 1274of user root.-- Subject: Unit session-1274.scope has finished start-up-- Defined-By: systemd-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

--

-- Unit session-1274.scope has finished starting up.--

-- The start-up result isdone.

Dec19 11:50:01 izwz932ypmamm80m434qqyz systemd[1]: Starting Session 1274of user root.-- Subject: Unit session-1274.scope has begun start-up-- Defined-By: systemd-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

--

-- Unit session-1274.scope has begun starting up.

Dec19 11:50:01 izwz932ypmamm80m434qqyz CROND[11642]: (root) CMD (/usr/lib64/sa/sa1 1 1)

启动失败,mysql告诉我可以执行后面两个命令看错误信息,我也做了,结果发现没鸟用。此时最好是能看到启动日志,可是我去/var/log目录一看,mysqld.log是空的。没办法,只能问万能的度娘了。按网友提供的一些建议,死马当活马医了。先是变更了mysql的数据文件目录,这件事虽然跟这个问题没啥关联,感觉这样做也是好的

mv /var/lib/mysql/ /data/

但启动依然失败,直接输入mysql报错:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

突然发现还有事情没干,改了目录没改配置!接着编辑配置文件/etc/my.cnf,修改所有的socket为

socket = /data/mysql/mysql.sock

让mysql找到mysql.sock文件了。在[mysql]下新增

[mysqld]

datadir=/data/mysql

让mysql找到数据目录。可是报错依旧,已经没辙了。无奈下试了给数据目录data/mysql加上系统权限:

[root@izwz932ypmamm80m434qqyz /]# chown -R mysql:mysql data/mysql

再次执行启动成功:

[root@izwz932ypmamm80m434qqyz log]# service mysqld start

Starting mysqld (via systemctl): [ OK ]

[root@izwz932ypmamm80m434qqyz log]# mysql

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection idis 2Server version:5.5.55-log MySQL Community Server (GPL) by Atomicorp

Copyright (c)2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracleis a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type'help;' or '\h' for help. Type '\c' to clear the current input statement.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值