WAMP本地部署WHMCS遇SQLSTATE[HY000][1045]数据库访问拒绝错误求助
Fixing WHMCS Database Access Denied Error (1045) on WAMP
Hey there, let's troubleshoot that annoying SQLSTATE[HY000] [1045] Access denied error you're hitting when setting up WHMCS on your local WAMP stack. This usually boils down to mismatched user credentials or permission issues, so let's walk through the fixes step by step:
1. Double-Check MySQL User Permissions in phpMyAdmin
First, let's make sure the test user has the correct setup:
- Open phpMyAdmin from your WAMP dashboard.
- Navigate to the User accounts tab.
- Find the
test@localhostentry and click Edit privileges. - In the Login Information section:
- Confirm the password matches exactly what you're entering in WHMCS (no typos, extra spaces, or wrong case).
- Ensure the Host name is set to
localhost—MySQL treatslocalhostand127.0.0.1as separate hosts, so match this value in your WHMCS setup.
- Scroll down to Global privileges and make sure the user has at least these WHMCS-required permissions:
SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, INDEX - Click Go to save changes.
2. Restart the MySQL Service
MySQL sometimes caches old credential data, so a quick restart can clear this up:
- Open your WAMP tray icon menu.
- Hover over MySQL > Click Restart Service.
- Wait 10-15 seconds for the service to reload, then try the WHMCS installation again.
3. Verify WHMCS Installation Form Inputs
It's easy to slip up with typos—double-check these fields in the WHMCS setup:
- Database Username: Confirm it's exactly
test(no accidental capitalization or spaces). - Database Password: Type it slowly, or copy-paste if you saved the password elsewhere (watch for special characters that might get mangled).
- Database Host: Try
localhostfirst; if that fails, switch to127.0.0.1(some WAMP configurations prioritize one over the other).
4. Test the Connection Manually (Optional)
To rule out WHMCS-specific issues, create a quick test script:
- In your WAMP
wwwfolder, make a new file namedtest_db_connection.php. - Paste this code (replace
your_password_herewith your actual password):<?php $host = 'localhost'; $user = 'test'; $pass = 'your_password_here'; $conn = mysqli_connect($host, $user, $pass); if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } echo "Successfully connected to MySQL!"; mysqli_close($conn); ?> - Visit
http://localhost/test_db_connection.phpin your browser:- If it shows "Successfully connected", the problem is in your WHMCS form input.
- If you still get the 1045 error, go back to step 1 to recheck the user's password and permissions.
Attached Screenshots
Installation Page: WHMCS Database Configuration Screen
Error Screen: MySQL Access Denied Error
内容的提问来源于stack exchange,提问作者Andreas
相关产品推荐
相关产品推荐

