Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Databases and Redis

MySQL or MariaDB will not start: unable to lock ibdata1

Error[ERROR] InnoDB: Unable to lock ./ibdata1 error: 11

Short answer

The error means the server could not take its exclusive lock on the InnoDB system tablespace. The usual reason is that another mysqld or mariadbd is already running on the same data directory. Find that process, stop it, and start only one server. If none exists, check file access rights.

  • Applies to MySQL 8.4, MariaDB 11
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Look for a server process that is already running. If one shows up, it holds the lock.

    ps xa | grep -E 'mysqld|mariadbd'
  2. 2Match what you see, then jump to its fix

    1. 1Error 11 (resource temporarily unavailable) on ibdata1, with the note about another process using the same InnoDB filesA second server instance already uses the same data directoryFix
    2. 2An operating system error on a file operation in the InnoDB lines of the error log, and no other server process in the first stepThe server cannot access the InnoDB data filesFix

What does the error look like?

  • [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
  • [Note] InnoDB: Check that you do not already have another mariadbd process using the same InnoDB data or log files.

Cause 1 of 2

A second server instance already uses the same data directory

1Check

Error 11 means the exclusive lock on ibdata1 could not be created, which typically means another instance is running on that data directory. List the processes and compare their data directory.

ps xa | grep -E 'mysqld|mariadbd'

2Fix

Stop the instance you do not want (or the one that is half-shutdown) and wait until its process is gone. Then start the server again. Never point two servers at one data directory.

sudo systemctl stop mysql
# or: sudo systemctl stop mariadb
ps xa | grep -E 'mysqld|mariadbd'

3Verify

No server process is listed, then the server starts and stays up.

sudo systemctl start mysql
# or: sudo systemctl start mariadb
sudo systemctl status mysql

Confirmed by mariadb.com

Did this fix it?

Cause 2 of 2

The server cannot access the InnoDB data files

1Check

The MySQL manual lists this for InnoDB operating system errors: the directory must exist and mysqld needs rights to create files in it; the disk must not be full. MariaDB asks for the whole datadir to be owned by the user running the server, usually mysql.

ls -ld /var/lib/mysql
ls -l /var/lib/mysql/ibdata1
df -h /var/lib/mysql

2Fix

Give the data directory to the server user and make sure the directory is on a disk that is not full. Change the path only if your server uses another datadir.

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

3Verify

Start the server and confirm it stays up.

sudo systemctl start mysql

Confirmed by dev.mysql.com

Did this fix it?

How do I stop it coming back?

  • Run one server per data directory; give every extra instance its own datadir, port and socket.
  • Stop the server through the service manager and wait for it to exit before starting it again.
  • Keep the datadir owned by the server user and watch its disk space.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.