rhel7 mysql无法运行_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失败的解决办法

4168c31c4579cd5fbbe0b9ea7a8319ad.png

[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**

45a409ffb4f0d3e3fa2197d8dc06b8f2.png

【解决办法】

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

befe2100ce5e56ed74b38d9ffc87a9a9.png

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)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值