You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WordPress网站数据库连接失败故障求助,MySQL启动失败无法修复

Fixing "Error establishing a database connection" with MySQL Startup Failures

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.cnf or /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 = 128M and lower it to a value your server can handle—try 64M or even 32M if your server has limited RAM.
  • Also, fix the deprecated settings mentioned in the warnings:
    • Replace key_buffer with key_buffer_size (e.g., key_buffer_size = 32M)
    • Replace myisam-recover with myisam-recover-options (e.g., myisam-recover-options = BACKUP)
  • 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):
    mysql -u YOUR_WP_DB_USER -p
    
    Enter your database password, then run use YOUR_WP_DB_NAME;—if this works, your database is accessible.
  • Double-check your wp-config.php file to ensure DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST are 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 08:48:02