• Resolved Dave Gear

    (@wordgear)


    I’ve installed WordPress in years past, but this time I’m trying it on Windows 10 Pro (latest update) with the latest WAMP and WordPress 5.2.5 (to match a production version), and I’ve set up a MySQL 5.7 database username (through phpMyAdmin) with an auto-generated matching database name with all privileges at @localhost and @_% (all of this was auto-created), and no matter what I do, it just won’t connect, and I’m not seeing where to find the exact error message.

    Note: I set up a virtual host in WAMP (and Windows hosts file) like wamp.local or phpmyadmin.local or wordpress.local, which all work perfectly fine.

    It doesn’t matter what I put in the WordPress install database connection settings, even if they all match, or how I config anything in the database, everything matches, I just cannot see the specific error from WordPress or MySQL on why it’s not connecting.

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Make sure the MySQL server is running. Can you access phpMyAdmin? Can you create a Database?

    Personally, I suggest you use “Laragon” instead of WAMP.

    You’ll fall in love with Laragon.

    Thread Starter Dave Gear

    (@wordgear)

    I’ve been working just fine in phpMyAdmin with the database the whole time… I’m literally changing things as I test to try to get something to work. The connection through there is just fine. I’m not doing anything unusual there. Even changing permissions from nothing to everything and anything in-between isn’t fixing it.

    The MySQL server is 5.7 and the default port 3306. This is driving me crazy.

    Thread Starter Dave Gear

    (@wordgear)

    I did figure out how to get a more-specific error message, by copying wp-config-sample.php to wp-config.php (even though install says to delete it, because I guess it’s supposed to generate it), filling out the DB info and unique phrase there, setting WP_DEBUG to true, and then re-running install – which says:

    Warning: mysqli_real_connect(): (HY000/2002): No connection could be made because the target machine actively refused it. in C:\wamp64\www\mydomain\wp-includes\wp-db.php on line 1612

    When I look at what values are being passed to mysqli_real_connect, they’re correct and match the info I put in wp-config.php for DB_HOST, DB_USER, DB_PASSWORD, and DB_NAME. I don’t specify a port because it’s supposed to use the default, 3306. The code on the prod server doesn’t specify a port, it just uses ‘localhost’ for DB_HOST (I use my custom domain name for mine of course, which matches the WAMP virtual host and works in the browser).

    I’m having trouble figuring out how phpMyAdmin submits the connection in the code exactly… but from what I can tell it looks similar.

    I read that “actively refused it” means the MySQL server is either not on (which it is) or not actively listening to the port (even though it’s config’d for 3306)…

    Something is just different about what WordPress is doing… is it submitting under a different default port? I don’t know how or why it would do that. How do I figure out why the error is happening?

    Dion

    (@diondesigns)

    Is your firewall blocking port 3306?

    Thread Starter Dave Gear

    (@wordgear)

    No, phpMyAdmin connects just fine…

    If you have done everything by the book and there still seems to be the annoying message ‘we are able to connect to the database server that means your username and password are fine but cannot find your database’, the error is probably in setting the localhost port. In earlier (prior to 5.7.28 SQL versions), putting in ‘localhost’ in the wp-config.php file for DB Host was fine. SQL 5.7.28 seems to use port 3308 for connection. Adding ‘localhost:3308’ for DB Host in the config file should fix the issue. You can also check to ensure this is indeed the problem by looking at localhost/phpmyadmin page. If at the top of the page it reads Server: MySQL:3308, then this fix should fix your problem. If your MySQL for any reason is using some other port, then putting in that port number in the config file should work.

    Thread Starter Dave Gear

    (@wordgear)

    It looks like WAMP MySQL is 5.7.28 and is using port 3308… Port 3306 tests as failure.

    My research is indicating that port 3308 is typically used for secondary instances of MySQL, but I’m not seeing another installation or previous version of MySQL. The person in this thread is running into the same issue apparently because something else previously installed MySQL at port 3306: https://stackoverflow.com/a/42544006

    I’m hoping 3306 is still the default for this version of MySQL… I don’t want to have trying to troubleshoot tooling can be so annoying.

    Thread Starter Dave Gear

    (@wordgear)

    I did change the DB_HOST in my WordPress config before I noticed your reply, and it did work.

    Now I’d like to get all MySQL connections to use port 3306, as it’s annoying to have different ones.

    I remembered I have MySQL Workbench installed, which I haven’t used for a while, and which apparently confiscated port 3306 and somehow caused WAMP to select 3308 for its own MySQL install… not sure how that works, as I didn’t even have MySQL installed and there was no service for it or the port that I could see either (and I’m having difficulty figuring out if 3306 is still effectively attached to anything, as I’ve already uninstalled Workbench).

    Thanks guys, this really helped. Changing the DB_HOST in wp-config.php to localhost:3308 sorted my problem.

    In answer to @wordgear – MariaDB is using port 3306. It got installed with the latest version of WampServer.

    I am sure you can switch those ports around so MariaDB uses 3308 & MySQL uses 3306.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Can’t see why database is not connecting no matter what I do’ is closed to new replies.