WordPress网站数据库连接失败故障求助,MySQL启动失败无法修复
Hey there, let’s work through your MySQL issue step by step—your logs show a few clear problems we can tackle to get your WordPress site back up.
1. Fix the InnoDB Memory Allocation Fatal Error
The most critical error here is:
InnoDB: Fatal error: cannot allocate memory for the buffer pool
Errno 12 means your server doesn’t have enough free memory to support the current innodb_buffer_pool_size setting (128M in your logs). Here’s how to fix it:
- Open your MySQL config file (usually at
/etc/mysql/my.cnfor/etc/mysql/mysql.conf.d/mysqld.cnf) with a text editor:sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf - Find the line
innodb_buffer_pool_size = 128Mand lower it to a value your server can handle—try64Mor even32Mif your server has limited RAM. - Also, fix the deprecated settings mentioned in the warnings:
- Replace
key_bufferwithkey_buffer_size(e.g.,key_buffer_size = 32M) - Replace
myisam-recoverwithmyisam-recover-options(e.g.,myisam-recover-options = BACKUP)
- Replace
- Save the file and exit (Ctrl+O, then Ctrl+X in nano).
2. Fix File Permissions for MySQL Data Directory
Your logs show permission errors creating test files in /var/lib/mysql:
Can't create test file /var/lib/mysql/chengtie.lower-test (errno: 13)
A simple chmod 755 isn’t enough—you need to ensure the mysql user owns the entire directory:
sudo chown -R mysql:mysql /var/lib/mysql sudo chmod -R 755 /var/lib/mysql
3. Repair the Missing mysql.plugin Table
Once the above fixes are applied, try starting MySQL again, then run the upgrade tool to rebuild missing system tables:
- Start MySQL with:
sudo service mysql start - If it starts successfully, run:
sudo mysql_upgrade
This will recreate the missing mysql.plugin table and fix any other system table inconsistencies.
4. Verify MySQL and WordPress Connection
- Check if MySQL is running properly:
sudo service mysql status - Test the database connection directly using your WordPress credentials (from
wp-config.php):
Enter your database password, then runmysql -u YOUR_WP_DB_USER -puse YOUR_WP_DB_NAME;—if this works, your database is accessible. - Double-check your
wp-config.phpfile to ensureDB_NAME,DB_USER,DB_PASSWORD, andDB_HOSTare all correct (no typos or outdated values).
Final Notes
If MySQL still fails to start after these steps, check your server’s free memory with free -m—if you’re almost out of RAM, you might need to upgrade your server or close other resource-heavy processes.
内容的提问来源于stack exchange,提问作者SoftTimur

