MySQL(Mariadb)启动失败

问题

修改/etc/my.conf文件中的数据保存目录后,mariadb启动失败。

排查

使用systemctl status mariadb.service查看原因

[root@linux-4-193 mysql]# systemctl status mariadb.service
● mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since 三 2022-01-12 21:02:39 EST; 2s ago
  Process: 11377 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=1/FAILURE)
  Process: 11375 ExecStart=/usr/bin/mysqld_safe --basedir=/usr (code=exited, status=0/SUCCESS)
  Process: 11247 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
 Main PID: 11375 (code=exited, status=0/SUCCESS)

112 21:02:38 linux-4-193 mariadb-prepare-db-dir[11247]: You can find additional information about the MySQL part at:
112 21:02:38 linux-4-193 mariadb-prepare-db-dir[11247]: http://dev.mysql.com
112 21:02:38 linux-4-193 mariadb-prepare-db-dir[11247]: Consider joining MariaDB's strong and vibrant community:
1月 12 21:02:38 linux-4-193 mariadb-prepare-db-dir[11247]: https://mariadb.org/get-involved/
1月 12 21:02:38 linux-4-193 mysqld_safe[11375]: 220112 21:02:38 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
112 21:02:38 linux-4-193 mysqld_safe[11375]: 220112 21:02:38 mysqld_safe Starting mysqld daemon with databases from /data/mysql
112 21:02:39 linux-4-193 systemd[1]: mariadb.service: control process exited, code=exited status=1
112 21:02:39 linux-4-193 systemd[1]: Failed to start MariaDB database server.
112 21:02:39 linux-4-193 systemd[1]: Unit mariadb.service entered failed state.
112 21:02:39 linux-4-193 systemd[1]: mariadb.service failed.
[root@linux-4-193 mysql]# ll

根据提示查看mariadb启动日志

[root@linux-4-193 mysql]# cat /var/log/mariadb/mariadb.log
220112 01:08:28 mysqld_safe Starting mysqld daemon with databases from /data/mysql
220112  1:08:28 [Note] /usr/libexec/mysqld (mysqld 5.5.68-MariaDB) starting as process 22271 ...
220112  1:08:28 [Warning] Can't create test file /data/mysql/linux-4-193.lower-test
220112  1:08:28 InnoDB: The InnoDB memory heap is disabled
220112  1:08:28 InnoDB: Mutexes and rw_locks use GCC atomic builtins
220112  1:08:28 InnoDB: Compressed tables use zlib 1.2.7
220112  1:08:28 InnoDB: Using Linux native AIO
220112  1:08:28 InnoDB: Initializing buffer pool, size = 128.0M
220112  1:08:28 InnoDB: Completed initialization of buffer pool
220112  1:08:28  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'create'.
InnoDB: Cannot continue operation.
220112 01:08:28 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended

The error means mysqld does not have the access rights to
可以看到是没有目录的处理权限。

解决

执行 chown mysql:mysql data 赋予mysql用户数据目录的权限即可。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值