Error: 1006 SQLSTATE: HY000 (ER_CANT_CREATE_DB)
Message: Can't create database '%s' (errno: %d)
How does the MySQL error message look like?
mysql> CREATE DATABASE test;
ERROR 1006 (HY000): Can't create database 'test' (errno: 13)
What does the MySQL error message mean?
The MySQL Server (mysqld process) can, for whatever reason, NOT create a schema/database.
Additional information you can get as follows:
shell> perror 13
OS error code 13: Permission denied
When does this MySQL error message happen?
This MySQL error usually happens when the MySQL data directory (datadir) does not belong to the user under which the mysqld process runs. For example the data directory belongs to the user root and the mysqld process runs as user mysql.
How to fix this MySQL error?
If the MySQL data directory does not belong to the user the mysqld process is running under, you can fix this for example as follows:
shell> sudo su -
shell> cd /var/lib
shell> chown -R mysql:mysql mysql
Alternatively you can start the mysqld process as follows:
shell> bin/mysqld_safe --user=mysql
or set the user accordingly in your my.cnf file.
# my.cnf
[mysqld]
user = mysql
Error: 1007 SQLSTATE: HY000 (ER_DB_CREATE_EXISTS)
Message: Can't create database '%s'; database exists
How does the MySQL error message look like?
mysql> CREATE SCHEMA test;
ERROR 1007 (HY000): Can't create database 'test'; database exists
What does the MySQL error message mean?
MySQL (the mysqld process) can, for whatever reason NOT create a schema/database.
When does this MySQL error message happen?
This MySQL error appears, as the error message states, when the database already exists.
How to fix this MySQL error?
You have 2 possibilities:
Choose an other name for your new database / schema.
Drop your old database / schema.
Rename your old database / schema (we can provide you more information, how to do this).
Error: 1013 SQLSTATE: HY000 (ER_CANT_GET_STAT)
Message: Can't get status of '%s' (errno: %d)
How does the MySQL error message look like?
mysql> CREATE DATABASE test;
ERROR 13 (HY000): Can't get stat of './test' (Errcode: 13)
What does the MySQL error message mean?
As you can see with the perror command:
shell> perror 13
OS error code 13: Permission denied
the mysqld process has not rights to write to the datadir (typically /var/lib/mysql/data) directory.
When does this MySQL error message happen?
This usually happens when you mix the usage of the user root and the database user (typically mysql). Often a directory is created with a user (root) which does not allow an other user (mysql) to access its files or directories.
How to fix this MySQL error?
Keep both roles (root and mysql) strictly separated.
If you are already in this situation you have to change the directory permissions:
shell> sudo su -
shell> cd /var/lib/mysql
shell> chown -R mysql:mysql data
Error: 1028 SQLSTATE: HY000 (ER_FILSORT_ABORT)
Message: Sort aborted
How does the MySQL error message look like?
In the MySQL error log you see:
120216 14:08:17 [ERROR] /usr/sbin/mysqld: Sort aborted
When does this MySQL error message happen?
Insufficient disk space in tmpdir
prevented tmpfile from being created.
Insufficient memory for sort_buffer_size
to be allocated.
Somebody ran KILL <id>
in the middle of a filesort.
The server was shutdown while some queries were sorting.
A transaction got rolled back or aborted due to lock wait timeout or deadlock.
Unexpected errors, such as source table or even tmp table was corrupt.
Processing of a subquery failed which was also sorting.
Shane Bester: [Bug 36022]
Message: Out of memory; check if mysqld or some other process uses
all available memory; if not, you may have to use 'ulimit' to
allow mysqld to use more memory or you can add more swap space
Error: 1045 SQLSTATE: 28000 (ER_ACCESS_DENIED_ERROR)
Message: Access denied for user '%s'@'%s' (using password: %s)
How does the MySQL error message look like?
mysql --user=nogo
ERROR 1045 (28000): Access denied for user 'nogo'@'localhost' (using password: NO)
shell> mysql --user=nogo --password=nogo
ERROR 1045 (28000): Access denied for user 'nogo'@'localhost' (using password: YES)
What does the MySQL error message mean?
This MySQL Error Message either means, that this user does not exist or that the password is not correct.
When does this MySQL error message happen?
This can happen when you connect with the wrong user to the database or when you use a password when no password is required or when you do not use a password when one is required or when you connect from the wrong host or over the socket/port when you are not allowed to.
How to fix this MySQL error?
Check the access privileges for this user like:
mysql> SELECT user, host FROM mysql.user WHERE user = 'nogo';
mysql> SHOW GRANTS FOR 'nogo'@'localhost';
Error: 1049 SQLSTATE: 42000 (ER_BAD_DB_ERROR)
Message: Unknown database '%s'
How does the MySQL error message look like?
shell> mysql -u root bla
ERROR 1049 (42000): Unknown database 'bla'
What does the MySQL error message mean?
This MySQL error message means that you try to connect to a database that does not exist.
When does this MySQL error message happen?
In the above example the database bla does not exist.
How to fix this MySQL error?
Either try to connect to an existing MySQL database (for example test or mysql). Or create a database with the according name:
mysql> CREATE SCHEMA bla;
1050 - 1099
MySQL, InnoDB and Oracle are registered trademarks of Oracle Corp. MariaDB is a trademark of Monty Program AB.
All other trademarks are property of their respective owners. Other product or company names mentioned may be trademarks or trade names of their respective owner.