0

UPDATE: 2020-07-12 I tried installing on Windows 10 64-bit and it failed to install WordPress with the same database error as on Windows 7. That tells me that either there is a bug in WAMPServer 3.2.0 or there is a bug in WordPress 5.4.2. because the issue occurs on both operating systems.


ISSUE

I'm installing WordPress on WAMP as a local development server, WordPress fails to install, so no config file is created.

Can’t select database

We were able to connect to the database server (which means your username and password is okay) but not able to select the wp_ehw_20200627 database.

Are you sure it exists?

Does the user root have permission to use the wp_ehw_20200627 database? On some systems the name of your database is prefixed with your username, so it would be like username_wp_ehw_20200627. Could that be the problem?

If you don’t know how to set up a database you should contact your host. If all else fails you may find help at the WordPress Support Forums.

MY SYSTEM DETAILS

  • Windows 7 Ultimate 64-bit
  • WAMPServer 3.2.0
  • WordPress 5.4.2

HERE IS WHAT I KNOW

  • The database exists and I can run SQL commands on it in phpMyAdmin.
  • My user is root
  • Host is localhost
  • Database is wp_ehw_20200627
  • root has all privileges to database (as verified in phpMyAdmin)

NOTE: I asked a similar question about a year ago, but this one is significantly different in that with the previous question WordPress was already installed, wheres in this scenario it is not.

THINGS I TRIED ALREADY

Suspecting that there might be issues with the naming of the database, I tried creating various empty databases for the install with different names. Success here is measured by whether or not the config.php file was created. Here are some of the names and results I tried:

  • wp_ehw_2020627 - failed
  • wpehw20200704 - failed
  • test - SUCCESS!

By using the db I created named "test", for the first time I got this SUCCESS message:

"All right, sparky! You’ve made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to…

Run the installation"

This result was encouraging, but that wasn't the database name I wanted. Suspect the issue was the length of the database name (in characters), I continued testing with differnt names, getting smaller in size each time.

  • ehw200704 - failed
  • 200704 - failed

Finally, since "test" was the only name that worked so far, I picked another easy four-letter word to test if four was the magic number.

  • john - failed

WEIRD ....

I also cleared Chrome cache in between each install attempt. I deleted the config file after success.

RESULTS

Only "test" created the config file.

I am very confused by these results.

Any help is appreciated.

2 Answers 2

0

First are you 100% sure you only have one MySQL server that both your PHPMyAdmin and WAMP can be connecting to?

If so, the easiest way to resolve this is start from scratch and setup a new MySQL user, a new database, then give that new user access to the database.

You need to connect to MySQL as your root/admin user (or run SQL commands through PHPMyAdmin), and any errors with these commands might shed some light on the issue. You need to run these commands exactly as shown, replacing the strings databasename, username, and password with whatever you want but leaving everything else exactly as shown:

CREATE DATABASE databasename;

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON databasename.* TO 'username'@'localhost'; 

FLUSH PRIVILEGES;

Taken from docs here

If these commands are all run successfully, and there's no possibility that you have different mysql servers, then afterwards you will definitely have a user username with password password who can access the database databasename. Obviously if you cut and paste anything wrong, or use different values when you setup Wordpress, it won't work ;-)

Hope that helps, please reply here if you're still stuck or if any of these commands give errors.

If you still have problems then sharing how you are viewing your databases, users and permissions will help debug.

11
  • Thanks. Ok, when you say "start from scratch and setup a new MySQL user" do you mean start from scratch by creating the new user, or start from scratch (as in reinstalling WampServer) in addition to creating the new user? Commented Jul 5, 2020 at 18:34
  • Sorry yeah, just start from scratch by creating a new user, as per this SQL. I don't think there's any reason to reinstall WAMP.
    – mozboz
    Commented Jul 5, 2020 at 18:38
  • Does the commands you provided create the new user? I tried that and I get this error: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY "passw0rd"' at line 1 Commented Jul 5, 2020 at 19:05
  • Here is the full line referred to in the error: GRANT ALL PRIVILEGES ON wp_ehw_20200705.* TO "eric"@"localhost" IDENTIFIED BY "passw0rd" Commented Jul 5, 2020 at 19:06
  • @EricHepperle-CodeSlayer2010 Sorry the SQL in the WP doc is a bit out of date, I've updated my answer with better syntax, give that a go
    – mozboz
    Commented Jul 5, 2020 at 19:14
0

Another potential issue is that the DB_USER has not been assigned privileges to the database even though the people with this problem know the valid username and password as well knows the valid database name.

The wp-config.php field values for the DB_NAME, DB_USER, and DB_PASSWORD may be correct.

The problem may have been caused when the user renamed the Database which causes a DROP and CREATE process for the database. Sometimes the renaming of the database is done in the phpMyAdmin tool and creates the problem.

Users who's web hosting service uses cPanel, phpMyAdmin and 'MySQL Databases' apps can simply "Add User to Database" using the cPanel's "MySQL Databases" That app provides dropdown lists of existing users and databases. During the process of associating the user to the database will also allow you to assigning user privileges to the database. Selecting "All" privileges will work if that is what is desired.

1
  • Thanks. That's good insight into possible issues. In my case, if I remember right, this turned out be an issue with WAMPServer in the sense that some update was needed because I changed my PHP version to 7 on localhost. I could be wrong about that though. Commented Feb 5, 2022 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.