I've followed this instructions, but after mysqld --skip-grant-tables --user=mysql, I'm getting this:

110913 20:29:18 [Warning] Can't create test file /var/lib/mysql/my-laptop.lower-test
110913 20:29:18 [Warning] Can't create test file /var/lib/mysql/my-laptop.lower-test
mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 2)
110913 20:29:18 [ERROR] Aborting
110913 20:29:18 [Note] mysqld: Shutdown complete

what I think it could be normal because the tutorial ask to do "rm -R /var/lib/mysql" on the step before. So I then create /var/lib/mysql, execute again "mysqld --skip......" and I get this:

110913 20:32:07 [Note] Plugin 'FEDERATED' is disabled.
110913 20:32:07  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'create'.
InnoDB: Cannot continue operation.

This is my /etc/my.cnf:

 # The following options will be passed to all MySQL clients
user            = mysql
#password    = your_password
port        = 3306
socket        = /var/run/mysqld/mysqld.sock

# Here follows entries for some specific programs

# The MySQL server
socket        = /var/run/mysqld/mysqld.sock
port        = 3306
basedir         = /usr/local/mysql
datadir         = /usr/local/mysql/data
tmpdir          = /tmp
log_error       = /var/log/mysql/error.log 
key_buffer_size = 256M
max_allowed_packet = 1M
table_open_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8

I have ubuntu 10.10.

Any idea?


3 Answers 3


The error means mysqld does not have the access rights to the directory.

When you recreated /var/lib/mysql, you need to make sure the /var/lib/mysql directory is owned and writeable by the mysql user.


Once you get your access rights back, don't forget to run mysql_install_db.

It will create the mysql schema and place it in /var/lib/mysql/mysql

Please comment out your datadir if you do not want the data in /usr/local/mysql/data

Also, run this

mkdir /var/log/mysql
chown mysql:mysql /var/log/mysql
mkdir /var/run/mysqld
chown mysql:mysql /var/run/mysqld

The fact that you are using Ubuntu and your datadir is not in the standard /var/lib/mysql directory as /usr/local/mysql/data means that apparmor is probably kicking you in the balls.

Check this post.

You could also check diagnostics in /var/log/syslog for apparmor messages. This last bit is useful because if you are using symbolic links, the messages in /var/log/syslog will tell you exactly what you need to put inside the /etc/apparmor.d/usr.sbin.mysqld file (you need to add two lines).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.