Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 grants for 'admin'@'%';
+---------------------------------------------------------------------------------------------------------------------------------+
| Grants for admin@%                                                                                                              |
+---------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' IDENTIFIED BY PASSWORD '*4ACFE3202A5FF5CF467898FC58AAB1D615029441' WITH GRANT OPTION |
+---------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> create database abc;
ERROR 1006 (HY000): Can't create database 'abc' (errno: 13)

Here is my users table.

mysql> select host, user from mysql.user;
+-------------+-------+
| host        | user  |
+-------------+-------+
| %           | admin |
| 127.0.0.1   | root  |
| ::1         | root  |
| IVM-MMC-DGW | root  |
| localhost   | admin |
| localhost   | root  |
+-------------+-------+
6 rows in set (0.00 sec)


mysql> show grants;
+-----------------------------------------------------------------------------------------------------------------------------------------+
| Grants for admin@localhost                                                                                                              |
+-----------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' IDENTIFIED BY PASSWORD '*4ACFE3202A5FF5CF467898FC58AAB1D615029441' WITH GRANT OPTION |
+-----------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

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 ?

like image 813
hardy_sandy Avatar asked Sep 10 '13 13:09

hardy_sandy


3 Answers

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
like image 89
Lucas Avatar answered Nov 14 '22 22:11

Lucas


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

like image 27
jfly Avatar answered Nov 14 '22 22:11

jfly


It might be problem with space. Follow this

  1. Check .err logs at /var/lib/mysql
  2. if the log says something like "[ERROR] Can't start server: can't create PID file: No space left on device"

  3. Check /var size by df -hk /var

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

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

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

  7. /etc/init.d/mysql restart

let me know if that worked :)

like image 20
sandejai Avatar answered Nov 14 '22 22:11

sandejai