Linux Redhat 6下MySQL5.1.73升级升级到MySQL5.7.26无法启动

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux Redhat 6下MySQL5.1.73升级升级到MySQL5.7.26无法启动相关的知识,希望对你有一定的参考价值。

A、getcwd cannot access parent directories错误解决方法,报文件或目录不存在

[root@localhost mysql]# service mysqld start
shell-init: error retrieving current directory: getcwd: cannot access parent directories: 没有那个文件或目录
chdir: error retrieving current directory: getcwd: cannot access parent directories: 没有那个文件或目录
MySQL Daemon failed to start.
正在启动 mysqld: [失败]

【解决方法】

该错误表示 getcwd 命令无法定位到当前工作目录。一般来说是因为你 cd 到了某个目录之后 rm 了这个目录,这时去执行某些 service 脚本的时候就会报 getcwd 错误。只需要 cd 到任何一个实际存在的目录下在执行命令即可。

B、从5.1.73升级到MySQL5.7.26后,启动MySQL失败的解决办法
技术图片

[root@localhost lib]# service mysqld start
MySQL Daemon failed to start.
正在启动 mysqld: [失败]
[root@localhost lib]# cat /var/log/mysqld.log
2020-03-16T05:05:23.424514Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-03-16T05:05:23.426403Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.26) starting as process 4710 ...
2020-03-16T05:05:23.430611Z 0 [Note] InnoDB: PUNCH HOLE support available
2020-03-16T05:05:23.430633Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-03-16T05:05:23.430639Z 0 [Note] InnoDB: Uses event mutexes
2020-03-16T05:05:23.430645Z 0 [Note] InnoDB: GCC builtin sync_synchronize() is used for memory barrier
2020-03-16T05:05:23.430650Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-03-16T05:05:23.430654Z 0 [Note] InnoDB: Using Linux native AIO
2020-03-16T05:05:23.430934Z 0 [Note] InnoDB: Number of pools: 1
2020-03-16T05:05:23.431056Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-03-16T05:05:23.432945Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2020-03-16T05:05:23.442045Z 0 [Note] InnoDB: Completed initialization of buffer pool
2020-03-16T05:05:23.444354Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2020-03-16T05:05:23.454655Z 0 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2020-03-16T05:05:23.454681Z 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2020-03-16T05:05:23.454691Z 0 [ERROR] InnoDB: os_file_get_status() failed on ‘./ibdata1‘. Can‘t determine file permissions
2020-03-16T05:05:23.454699Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2020-03-16T05:05:24.055542Z 0 [ERROR] Plugin ‘InnoDB‘ init function returned error.
2020-03-16T05:05:24.055598Z 0 [ERROR] Plugin ‘InnoDB‘ registration as a STORAGE ENGINE failed.
2020-03-16T05:05:24.055610Z 0 [ERROR] Failed to initialize builtin plugins.
2020-03-16T05:05:24.055618Z 0 [ERROR] Aborting

2020-03-16T05:05:24.055654Z 0 [Note] Binlog end
2020-03-16T05:05:24.056209Z 0 [Note] /usr/sbin/mysqld: Shutdown complete**

技术图片

【解决办法】
1、MySQL重新初始化
#日志中报错如下:
[ERROR] Fatal error: mysql.user table is damaged. Please run mysql_upgrade.
[ERROR] Aborting
#解决的办法就是重新初始化数据库

[root@localhost lib]# rm -fr /var/lib/mysql
[root@localhost lib]# mysqld --initialize --user=mysql

2、查看配置文件内容指定的pid-file

[root@localhost lib]# cat /etc/my.cnf
pid-file=/var/run/mysqld/mysqld.pid

查看该目录是否存在。如没有,则创建,并修改属主属组。

[root@localhost lib]# ll /var/run/mysqld/
#不存在
[root@localhost lib]# mkdir -p /var/run/mysqld/
[root@localhost lib]# chown -R mysql:mysql /var/run/mysqld

重启:

[root@localhost lib]# service mysqld restart

如果还报错,则进入下一步。

3、关闭selinux.并重启。

[root@localhost lib]# setenforce 0
[root@localhost lib]# service mysqld restart

技术图片

4、善后工作
查看MySQL初始化密码

[root@localhost lib]# cat /var/log/mysqld.log | grep ‘temporary password‘
2020-03-16T05:16:48.202073Z 1 [Note] A temporary password is generated for root@localhost: uRcin>y7sT9%
2020-03-16T05:19:40.763447Z 1 [Note] A temporary password is generated for root@localhost: cS/>l%Ddi7lu

登录

[root@localhost lib]# mysql -uroot -p‘cS/>l%Ddi7lu‘
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 10
Server version: 5.7.26

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

Oracle is 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.

mysql>

修改密码

mysql> alter user root@localhost identified by ‘123456‘;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

以上是关于Linux Redhat 6下MySQL5.1.73升级升级到MySQL5.7.26无法启动的主要内容,如果未能解决你的问题,请参考以下文章

Linux Redhat 6下MySQL5.1.73升级升级到MySQL5.7.26无法启动

RedHat Enterprise Linux 6 配置Xmanager ,实现图形界面连接

redhat linux 6.2 安装配置GUI

Redhat 6.9下搭建本地yum源

Linux Redhat 6.5 中防火墙

linux redhat 6.5 添加EMC新lun不需要重启系统的办法