无法连接SQLYogUltimate数据库至WordPress 4.5.1,凭证正确仍报错求助
Hey there! Let's work through this frustrating issue—you're positive your database credentials are correct, but WordPress keeps throwing that connection error. Here are the most common fixes to try:
Confirm your MySQL server is running
Sometimes the problem isn't your credentials at all—it's that the database server isn't active. First, try connecting directly to your MySQL server using SQLYogUltimate (without going through WordPress). If that fails:- On Windows: Open the Services panel, find your MySQL service, and make sure it's set to "Running".
- On Linux: Run
sudo systemctl status mysqlin the terminal to check the service state.
Adjust the
DB_HOSTvalue inwp-config.php
WordPress defaults tolocalhost, but some MySQL configurations only accept connections via127.0.0.1(the IPv4 loopback address). Try updating yourwp-config.phpline to:define('DB_HOST', '127.0.0.1:3306');(If you've changed your MySQL port from the default 3306, replace that number with your custom port.)
Verify database user permissions
A correct username/password doesn't guarantee the user has access to your WordPress database. Open SQLYog, log into MySQL, and run these commands (replace placeholders with your actual details):GRANT ALL PRIVILEGES ON your_wordpress_database.* TO 'your_db_username'@'localhost' IDENTIFIED BY 'your_db_password'; FLUSH PRIVILEGES;This ensures the user has full access to the database from localhost.
Double-check the database exists
It's easy to assume the database was created successfully, but sometimes it's not. In SQLYog, browse your server's databases to confirm the name matches exactly what's inDB_NAMEinwp-config.php. If it's missing, create it first.Hunt for hidden typos in
wp-config.php
Even if you're sure there are no mistakes, small errors can slip through:- Case sensitivity: MySQL on Linux distinguishes between uppercase and lowercase database/table names—make sure your
DB_NAMEmatches exactly. - Extra spaces: Accidental spaces around your username or password will break the connection. Copy the values directly from
wp-config.phpinto SQLYog's login field to test them.
- Case sensitivity: MySQL on Linux distinguishes between uppercase and lowercase database/table names—make sure your
Check MySQL version compatibility
WordPress 4.5.1 requires MySQL 5.0.15 or newer. Run this query in SQLYog to confirm your version:SELECT VERSION();If your MySQL version is older, you'll need to update it to get the connection working.
内容的提问来源于stack exchange,提问作者Stack_august

