Getting "mysql errno 2" when trying to create a new database

Skip to first unread message


Jan 8, 2009, 12:19:13 AM1/8/09
to Sequel Pro
Hello. I am pretty inexperienced with administrating mysql locally,
and am running into some issues.

I have installed the latest version of mysql, connected to my default
database with Sequel Pro, and then have failed to create a new
database. Whenever I try, I get "MySQL said: Can't create database
'test' (errno: 2)".

I have no idea what this means. Can anyone help?


Rowan Beentje

Jan 8, 2009, 11:22:31 AM1/8/09
to Sequel Pro
errno: 2 tends to be file or directory issues - it's probably trying
to create the database file on disk, and miserably failing :)

When you installed the latest version of mysql, did you follow all the
steps required after installation - like chowning the var or data
directory (depending on how you installed it) to the mysql user?

One of the eventual aims for the Sequel Pro website is a series of
help pages for issues exactly like these!

Aaron Curry

Jan 8, 2009, 11:56:05 PM1/8/09
I followed all the directions given here:

They didn't mention chowining anything.  Am I looking at the wrong bit, here?


Rowan Beentje

Jan 9, 2009, 9:38:46 AM1/9/09
to Sequel Pro
Hmm, It does appear that the installer should do everything for you,
but I'm guessing it's gone wrong somewhere along the way. If you open
up a terminal, and `cd /usr/local/mysql/` and `ls -la`, what owner/
permissions does it have for the var/data directory?

Paul Saieg

Feb 10, 2009, 5:42:46 PM2/10/09
to Sequel Pro
I ran across this once, when it happened to me ls -la gave all the
right permissions for mysql.
These are the notes from my solutions log:

Problem: Mysql cannot find databases or create new ones

> sudo mysqladmin -u root create db_production
mysqladmin: CREATE DATABASE failed; error: 'Can't create database
'db_production' (errno: 2)'

mysql> show databases;
| Database |
| information_schema |
1 row in set (0.00 sec)

> sudo find / -name db_production

mysql> CREATE DATABASE db_production;
ERROR 1006 (HY000): Can't create database 'db_production' (errno:

Root Cause: Mysql's path is set incorrectly. It is looking somewhere
other than the dir where the dbs live

Solution: In /etc/mysql/my.cnf, set datadir = /home/mysql_data, which
is the location where the database files actually live on my machine
(as the find command above shows)


Mar 5, 2009, 7:10:43 PM3/5/09
to Sequel Pro
Aaron - I just encountered the exact same problem. The permissions and
everything were correct, but I still couldn't create any databases. I
also couldn't see the default test and mysql databases. I finally
restarted my computer and everything just worked!
Reply all
Reply to author
0 new messages