• I’m having an issue with a local WordPress install using MAMP (fully updated) on a Mac. I’m getting the “No database selected” message. And, this is happening on a clean install of WordPress 5.4 before anything has been modified. MySQL version is 5.7.26.

    I’ve checked PHYMyAdmin and the root user and the other user that I set up for the DB both have the correct “All Privileges” settings. I created a test.php script to test my DB credentials and the connection is successful.

    My issue is that the “no database selected” error displays after upgrading my PHP. If I select any version greater than PHP 7.1.32, I get the error. As soon as I switch it back, the website works. So, I don’t believe that this is a DB issue in my case. This same behavior happens on every site that I have set up in MAMP. The only variable is switching the PHP version to a current one.

    ** ERROR **
    No database selected

    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 database.

    Are you sure it exists?
    Does the user have permission to use the database?
    On some systems the name of your database is prefixed with your username, so it would be like username_. Could that be the problem?

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    What have you specified for DB_HOST in wp-config.php? Most generally use “localhost” but the default port could already be in use. In that case you need to explicitly specify the port used by MAMP for MySQL, such as “localhost:8889”. Determine the port MAMP is using from its control panel preferences.

    Thread Starter jbdegarmo

    (@jbdegarmo)

    I tried that already. It doesn’t matter if I use “localhost” or “localhost:3306” for the DB_HOST. MAMP has 3306 as the default MySQL port. When I log into PHPMyAdmin the database host is “localhost:3306”. I’ve even tried making sure that the PHP.ini file has 3306 as the default – same error whether that value is blank or with 3306.

    I first noticed then after setting up a fresh WP install. After installing the theme, the WP Site Health page mentioned that I should upgrade to at least PHP 7.3. When I set it up in MAMP, it was using 7.033. So, I tried switching from 7.033 to 7.42 and restarting Apache/MySQL and that’s when the error appeared. I checked several other local WP sites and they all did the same thing when switched the PHP version.

    As a test, I completely deleted the new WP install and started from scratch after updating the default PHP Version to 7.42. During the WP install process, I got to the page where you enter the DB credentials, but it failed there with a similar error. At that time the DB Name and DB User were different. I did finally get it to install after setting the DB Name and DB User to be identical. Why is that a requirement for WP install properly to work properly (or for a website upgrading its PHP version)?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘No Database Selected’ is closed to new replies.