当前位置: 首页 > 工具软件 > binary_log > 使用案例 >

安装mysql5.7异常:mysqld: File '/var/lib/mysql/mysql_binary_log.index' not found

孔飞舟
2023-12-01
名称版本号
mysql-5.7.26-el7-x86_64.tar.gzmysql-5.7
1.在执行mysql初始化指令时抛出异常

[root@localhost bin]# ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql-5.7 --datadir=/usr/local/mysql-5.7/data

.mysqld: File ‘/var/lib/mysql/mysql_binary_log.index’ not found(No such file or directory)

2.根据提示创建mysql_binary_log.index文件

[root@localhost bin]#touch /var/lib/mysql/mysql_binary_log.index

此时会发现"/var/lib/mysql"文件夹不存在,需要先创建“mysql文件夹”后创建“mysql_binary_log.index”文件

3.先创建文件夹,后创建文件

[root@localhost bin]#mkdir /var/lib/mysql
[root@localhost bin]#touch /var/lib/mysql/mysql_binary_log.index

4.文件夹赋权

将名称为“mysql”的文件夹拥有者权限赋予给“mysql”用户,否则会提示无权写入文件:“permission denied”;
在配置mysql安装流程中,博主执行以下指令为CentOS系统增加了“mysql”用户

[root@izwz93iqzu25txre8gk673z support-files]# groupadd mysql
[root@izwz93iqzu25txre8gk673z support-files]# useradd -r -g mysql mysql
[root@izwz93iqzu25txre8gk673z support-files]# chown -R mysql:mysql /usr/local/mysql-5.7/

因而授予文件夹权限时,指定文件夹拥有者为“mysql”;若您配置了其他用户名称,请自行替换为您配置的用户名

[root@localhost mysql]# chown -R mysql:mysql /var/lib/mysql/

可以看到“mysql”的文件夹归属用户已经是“mysql用户”
[root@localhost mysql]# ll
total 0
-rw-r–r--. 1 mysql mysql 0 Aug 1 09:48 mysql_binary_log.index

5.重新执行mysql的initialize操作

[root@localhost bin]# ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql-5.7 --datadir=/usr/local/mysql-5.7/data
100 200 300 400 500
100 200 300 400 500
2019-08-01T13:55:22.787470Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-08-01T13:55:22.841504Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-08-01T13:55:22.906139Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 01a884b0-b464-11e9-b874-080027452298.
2019-08-01T13:55:22.906920Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed’ cannot be opened.
2019-08-01T13:55:22.908159Z 1 [Note] A temporary password is generated for root@localhost: ,Z+ia/QsQ1Mf

初始化成功并输出登录密码

 类似资料: