can't select mysql database_ERROR 1006 (HY000) Can't create database (errno: 13) MySQL 5.6.12

可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):

问题:

I am facing problem creating the database and it results in following error. mysql>show grantsfor'admin'@'%';+---------------------------------------------------------------------------------------------------------------------------------+|Grantsforadmin@%|+---------------------------------------------------------------------------------------------------------------------------------+|GRANT ALL PRIVILEGES ON*.*TO'admin'@'%'IDENTIFIED BY PASSWORD'*4ACFE3202A5FF5CF467898FC58AAB1D615029441'WITH GRANT OPTION|+---------------------------------------------------------------------------------------------------------------------------------+1rowinset(0.00sec)mysql>create database abc;ERROR1006(HY000):Can't create database 'abc' (errno: 13)

Here is my users table. mysql>selecthost,userfrommysql.user;+-------------+-------+|host|user|+-------------+-------+|%|admin||127.0.0.1|root||::1|root||IVM-MMC-DGW|root||localhost|admin||localhost|root|+-------------+-------+6rowsinset(0.00sec)mysql>show grants;+-----------------------------------------------------------------------------------------------------------------------------------------+|Grantsforadmin@localhost|+-----------------------------------------------------------------------------------------------------------------------------------------+|GRANT ALL PRIVILEGES ON*.*TO'admin'@'localhost'IDENTIFIED BY PASSWORD'*4ACFE3202A5FF5CF467898FC58AAB1D615029441'WITH GRANT OPTION|+-----------------------------------------------------------------------------------------------------------------------------------------+1rowinset(0.00sec)

I can create and remove table in the existing database.

The data directory already has mysql:mysql privileges and also the logged in user has privilege to create the new database.

What configuration is missing here ?

回答1:

There may be a permissions issue with the MySQL data directory. You could try setting the permissions as follows (adjust the path to your data directory) chown-R mysql:mysql/usr/local/mysql/data

回答2:

This happens probably due to permission denied by MySQL. Though you set the datadir=/drbd0/mysql/data, but by default MySql set socket = /var/lib/mysql/mysql.sock, so you should have the privileges to that directory. less/etc/group

and then less/etc/passwd

find mysql user and group name, by default, it's mysql user in mysql group.

change to mysql dir, probably /var/lib/mysql and then type cd .. to go up one directory. chown-R mysql:mysql./mysql/

Replace mysql:mysql with something different if you group and user privileges are called differenty

回答3:

It might be problem with space. Follow this Check .err logs at /var/lib/mysql

if the log says something like "[ERROR] Can't start server: can't create PID file: No space left on device"

Check /var size by df -hk /var

if used is 100% , then u have to find the files which is geting filled.

find large file in /var by find /var/ -type f -size +100000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'

see which file you can delete and then restart the mysql process by

/etc/init.d/mysql restart

let me know if that worked :)

回答4:

sudo chown -R mysql:mysql /var/lib/mysql/

回答5:

For Mac OS use this command sudo chown-R mysql:mysql/usr/local/mysql*

User mysql should have write access to mysql data directory.

回答6:

In /etc/mysql/my.cnf, set datadir = /home/mysql_data, which is the location where the database files actually are on yourmachine

回答7:

if you move the mysql folder you restart mysql, it works

回答8:

Same issue, in my case I changed the default directory on my.cf and the selinux has blocking it.

To test: setenforce0

To fix (CentOS)

Add context and make it permanent semanage fcontext-a-s system_u-tmysqld_db_t"/var/data/mysql(/.*)?"restorecon-Rv/var/data/mysql

回答9:

Turn off SELinux especially if you're on CentOS.

回答10:

Check your mysql data directory permissions. The data directory is configured in '/etc/my.conf' by default. Or use mysqladmin -uroot -p variables | grep datadir to find the directory. It may be /var/lib/mysql/ by default, and makesure the owner user and group is mysql. chown -R mysql:mysql /usr/local/mysql/data

If it has not been solved by step 1. It may be because of SELinux in your way, try to turn off it. Test if SELinux is running. selinuxenabled && echo enabled || echo disabled

Turning off SELinux temporarily. echo 0 > /selinux/enforce

Completely turning off SELinux. Change config SELINUX=disabled, and reboot.

In different os, the configuration directory of SELinux may be different.

回答11:

Running WAMP and i had same issue, opted for the traditional stop and start all services and that did it for me. I was able to create the database after that, really don't know why i wasn't able to create it at first as i had no issue with space or permission. Well i hope this helps the WAMP users

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值