Mysql启动报错:InnoDB: Operating system error number 13 in a file operation.的解决方法

安装完MYSQL后,修改了my.cnf 下的数据存储路径后,启动失败

修改路径前启动成功,修改后无法启动

#datadir=/var/lib/mysql
datadir=/home/bigdata/mysql_data/mysql
#socket=/var/lib/mysql/mysql.sock
socket=/home/bigdata/mysql_data/mysql/mysql.sock

错误信息:

Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.


log-error=/var/log/mysqld.log

通过查看,日志。cat /var/log/mysqld.log

 看到的错误信息:Operating system error number 13 in a file operation.

如下:

2023-09-27T09:59:26.154790Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp serv
er option (see documentation for more details).
2023-09-27T09:59:26.155096Z 0 [Warning] Can't create test file /home/bigdata/mysql_data/mysql/localhost.lower-test
2023-09-27T09:59:26.155165Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.43) starting as process 10953 ...
2023-09-27T09:59:26.158154Z 0 [Warning] Can't create test file /home/bigdata/mysql_data/mysql/localhost.lower-test
2023-09-27T09:59:26.158185Z 0 [Warning] Can't create test file /home/bigdata/mysql_data/mysql/localhost.lower-test
2023-09-27T09:59:26.160099Z 0 [Note] InnoDB: PUNCH HOLE support available
2023-09-27T09:59:26.160134Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2023-09-27T09:59:26.160140Z 0 [Note] InnoDB: Uses event mutexes
2023-09-27T09:59:26.160143Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2023-09-27T09:59:26.160147Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.13
2023-09-27T09:59:26.160150Z 0 [Note] InnoDB: Using Linux native AIO
2023-09-27T09:59:26.160424Z 0 [Note] InnoDB: Number of pools: 1
2023-09-27T09:59:26.160559Z 0 [Note] InnoDB: Using CPU crc32 instructions
2023-09-27T09:59:26.162480Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2023-09-27T09:59:26.170725Z 0 [Note] InnoDB: Completed initialization of buffer pool
2023-09-27T09:59:26.172894Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the 
man page of setpriority().
2023-09-27T09:59:26.182942Z 0 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2023-09-27T09:59:26.182958Z 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2023-09-27T09:59:26.182963Z 0 [ERROR] InnoDB: os_file_get_status() failed on './ibdata1'. Can't determine file permissions
2023-09-27T09:59:26.182987Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2023-09-27T09:59:26.783851Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2023-09-27T09:59:26.783882Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2023-09-27T09:59:26.783891Z 0 [ERROR] Failed to initialize builtin plugins.
2023-09-27T09:59:26.783921Z 0 [ERROR] Aborting

是系统问题,解决方案如下:

root@localhost mysql_data]#               getenforce
Enforcing
[root@localhost mysql_data]# setenforce 0 
[root@localhost mysql_data]# getenforce
Permissive

重启成功
[root@localhost mysql_data]# systemctl start mysqld
[root@localhost mysql_data]# ss -antulp | grep :3306
tcp    LISTEN     0      80     [::]:3306               [::]:*                   users:(("mysqld",pid=11050,fd=30)

)

你可能感兴趣的:(数据库)