MySQL or MariaDB will not start: unable to lock ibdata1
[ERROR] InnoDB: Unable to lock ./ibdata1 error: 11Short 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.
Fix it fast
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'2Match what you see, then jump to its fix
- 1
Error 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
An 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
- 1
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 mysqlConfirmed by mariadb.com
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/mysql2Fix
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/mysql3Verify
Start the server and confirm it stays up.
sudo systemctl start mysqlConfirmed by dev.mysql.com
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- ShopGoAn e-commerce aggregator with a Python scraping engine behind its catalog, past 10K Google Play downloads.
Related fixes
Databases
MySQL start fails with: the server quit without updating the PID file
Can't start server: Bind on TCP/IP port: Address already in use
This message is only a symptom: mysqld started and exited before it wrote its PID file.
3 causes, each with a fixDatabases
Installing the Airflow MySQL provider fails on pkg-config or mysqlclient
Building the mysqlclient wheel fails during the install
The Airflow MySQL provider depends on mysqlclient, which pip compiles against the MySQL C client library.
2 causes, each with a fixDatabases
A query on Aurora MySQL dies with 'table /rdsdbdata/tmp/#sql... is full'
ERROR 1114 (HY000): The table '/rdsdbdata/tmp/#sqlfd_1586_2' is full
In Aurora MySQL 3, internal temporary tables share one pool, and when that pool and the memory-mapped overflow file are used up, a reader instance ends the query with error 1114.
3 causes, each with a fixDatabases
Azure Database for MySQL refuses a connection that does not use SSL
ERROR 3159 (HY000): Connections using insecure transport are prohibited while --require_secure_transport=ON.
Azure Database for MySQL Flexible Server requires encrypted connections by default (require_secure_transport = ON, TLS 1.2).
4 causes, each with a fixDatabases
Compiling a C or C++ program that includes mysql.h fails
undefined reference to `mysql_init'
The compiler only finds mysql.h when the MySQL client development files are installed and their folder is on the include path.
3 causes, each with a fixDatabases
DBeaver fails to resolve Maven dependencies when downloading a database driver
A driver library does not download automatically
DBeaver downloads driver jars from a Maven repository.
3 causes, each with a fix