mysql用root用户启动后其他用户无法启动不问题

问题描述:用root账户启动mysql后,在用mysql用户或其他非root账户启动不了mysql
问题解决:通过看mysql的err日志,发现 Failed to open log (robert-bin.000013, errno 13),
查看错误号[root@robert logs]# perror 13 看到OS error code  13:  Permission denied。 
cd /data/mysql/mysql_3306/logs,ll看到binlog和err日志权限都变成root,执行chown mysql:mysql -R /data/mysql/mysql_3306/
后,就可以用mysql用户启动啦
问题原因:用root用户启动后,产生的binlog和errlog文件的权限就变啦

案例如下:
[root@robert logs]# mysqld_safe --user=root &
[1] 6064
[root@robert logs]# 141231 09:38:43 mysqld_safe Logging to '/data/mysql/mysql_3306/logs/robert.err'.
141231 09:38:43 mysqld_safe Starting mysqld daemon with databases from /data/mysql/mysql_3306/data

[root@robert logs]# /etc/init.d/mysqld status
MySQL running (6412)[  OK  ]

[root@robert logs]#mysqladmin -uroot -p123456 shutdown 
[root@robert logs]# /etc/init.d/mysqld start           //默认是mysql用户启动,ysqld_safe --user=mysql &
Starting MySQL...The server quit without updating PID file (/data/mysql/mysql_3306/data/robert.localdomain.pid).[FAILED]

[root@robert logs]# tail -f robert.err 
141231 08:58:25 mysqld_safe Starting mysqld daemon with databases from /data/mysql/mysql_3306/data
141231  8:58:25 [Note] Plugin 'FEDERATED' is disabled.
141231  8:58:25 InnoDB: The InnoDB memory heap is disabled
141231  8:58:25 InnoDB: Mutexes and rw_locks use GCC atomic builtins
141231  8:58:25 InnoDB: Compressed tables use zlib 1.2.3
141231  8:58:25 InnoDB: Using Linux native AIO
141231  8:58:25 InnoDB: Initializing buffer pool, size = 128.0M
141231  8:58:25 InnoDB: Completed initialization of buffer pool
141231  8:58:25 InnoDB: highest supported file format is Barracuda.
141231  8:58:25  InnoDB: Waiting for the background threads to start
141231  8:58:26 InnoDB: 5.5.37 started; log sequence number 396477665
/usr/local/mysql/bin/mysqld: File '/data/mysql/mysql_3306/logs/robert-bin.000013' not found (Errcode: 13)
141231  8:58:26 [ERROR] Failed to open log (file '/data/mysql/mysql_3306/logs/robert-bin.000013', errno 13)
141231  8:58:26 [ERROR] Could not open log file
141231  8:58:26 [ERROR] Can't init tc log
141231  8:58:26 [ERROR] Aborting


[root@robert logs]# perror 13
OS error code  13:  Permission denied   //没访问权限
[root@robert logs]# 
[root@robert logs]# pwd
/data/mysql/mysql_3306/logs
[root@robert logs]# ll
total 65812
-rw-rw---- 1 mysql mysql      126 Dec 28 10:56 robert-bin.000001
-rw-rw---- 1 mysql mysql      126 Dec 28 10:58 robert-bin.000002
-rw-rw---- 1 mysql mysql      126 Dec 28 11:11 robert-bin.000003
-rw-rw---- 1 mysql mysql     1297 Dec 29 10:05 robert-bin.000004
-rw-rw---- 1 mysql mysql 12592454 Dec 29 10:48 robert-bin.000005
-rw-rw---- 1 mysql mysql  4199546 Dec 29 12:28 robert-bin.000006
-rw-rw---- 1 mysql mysql 16792962 Dec 29 14:01 robert-bin.000007
-rw-rw---- 1 mysql mysql      558 Dec 29 14:19 robert-bin.000008
-rw-rw---- 1 mysql mysql      126 Dec 29 14:22 robert-bin.000009
-rw-rw---- 1 mysql mysql      461 Dec 30 14:09 robert-bin.000010
-rw-rw---- 1 root  root       386 Dec 31 08:42 robert-bin.000011
-rw-rw---- 1 root  root       126 Dec 31 08:48 robert-bin.000012
-rw-rw---- 1 root  root       126 Dec 31 08:50 robert-bin.000013
-rw-rw---- 1 mysql mysql      598 Dec 31 08:49 robert-bin.index
-rw-r----- 1 mysql root     33101 Dec 31 08:58 robert.err
-rw-rw---- 1 mysql mysql 33626181 Dec 31 08:58 robert.log
-rw-rw---- 1 mysql mysql     4421 Dec 31 08:58 robert-slow.log
[root@robert logs]# 
[root@robert logs]# 
[root@robert logs]# chown mysql:mysql -R /data/mysql/mysql_3306/
[root@robert logs]# ll
total 65812
-rw-rw---- 1 mysql mysql      126 Dec 28 10:56 robert-bin.000001
-rw-rw---- 1 mysql mysql      126 Dec 28 10:58 robert-bin.000002
-rw-rw---- 1 mysql mysql      126 Dec 28 11:11 robert-bin.000003
-rw-rw---- 1 mysql mysql     1297 Dec 29 10:05 robert-bin.000004
-rw-rw---- 1 mysql mysql 12592454 Dec 29 10:48 robert-bin.000005
-rw-rw---- 1 mysql mysql  4199546 Dec 29 12:28 robert-bin.000006
-rw-rw---- 1 mysql mysql 16792962 Dec 29 14:01 robert-bin.000007
-rw-rw---- 1 mysql mysql      558 Dec 29 14:19 robert-bin.000008
-rw-rw---- 1 mysql mysql      126 Dec 29 14:22 robert-bin.000009
-rw-rw---- 1 mysql mysql      461 Dec 30 14:09 robert-bin.000010
-rw-rw---- 1 mysql mysql      386 Dec 31 08:42 robert-bin.000011
-rw-rw---- 1 mysql mysql      126 Dec 31 08:48 robert-bin.000012
-rw-rw---- 1 mysql mysql      126 Dec 31 08:50 robert-bin.000013
-rw-rw---- 1 mysql mysql      598 Dec 31 08:49 robert-bin.index
-rw-r----- 1 mysql mysql    33101 Dec 31 08:58 robert.err
-rw-rw---- 1 mysql mysql 33626181 Dec 31 08:58 robert.log
-rw-rw---- 1 mysql mysql     4421 Dec 31 08:58 robert-slow.log


[root@robert logs]# mysqld_safe --user=mysql &
[1] 6470
[root@robert logs]# 141231 09:40:08 mysqld_safe Logging to '/data/mysql/mysql_3306/logs/robert.err'.
141231 09:40:08 mysqld_safe Starting mysqld daemon with databases from /data/mysql/mysql_3306/data

[root@robert logs]# 
[root@robert logs]# /etc/init.d/mysqld status
MySQL running (6818)[  OK  ]

注:用root用户启动不mysql,产生的文件权限就是root啦。导致其他用户不能读写,禁用root启动。

转载于:https://www.cnblogs.com/taotaohappy/p/4231924.html

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值