欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

报错!!!MySQL在安装过程中的报错

程序员文章站 2022-03-11 16:24:56
...

一、报错问题

[[email protected] data]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf &[1] 3758 
[[email protected] data]# 170720 14:41:24 mysqld_safe Logging to '/data/mysql/error.log'. 
201207 14:41:24 mysqld_safe Starting mysqld daemon with databases from /data/mysql201207  
14:41:25 mysqld_safe mysqld from pid file /data/mysql/node4.pid ended 
201207 14:41:24 mysqld_safe Starting mysqld daemon with databases from /data/mysql2020-12-07  
14:41:25 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. 
Please use --explicit_defaults_for_timestamp server option  
(see documentation for more details)./usr/local/mysql/bin/mysqld:  
File '/data/mysql/mysql-bin.index' not found (Errcode: 13 - Permission denied) 
2020-12-07 14:41:25 4388 [ERROR] Aborting 

二、解决思路

  • 遇到这样的报错信息,我们要学会时时去关注错误日志 error log 里面的内容。看见了关键的报错点Permission denied,证明当前 MySQL 数据库的数据目录没有权限。

三、解决方法

[[email protected] data]# chown mysql:mysql -R mysql 
[[email protected] data]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf & 
[1] 4402 
[[email protected] data]# 170720 14:45:56 mysqld_safe Logging to '/data/mysql/error.log'. 
201207 14:45:56 mysqld_safe Starting mysqld daemon with databases from /data/mysql 

启动成功。

四、如何避免这类问题

  • 如何避免这类问题,个人建议在安装 MySQL 初始化的时候,一定加上–user=mysql,这样就可以避免权限问题。
./mysql_install_db --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --defaults-file=/etc/my.cnf --user=mysql