Title: No Database Selected
Last modified: April 23, 2020

---

# No Database Selected

 *  [jbdegarmo](https://wordpress.org/support/users/jbdegarmo/)
 * (@jbdegarmo)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/no-database-selected-3/)
 * 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](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fno-database-selected-3%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/no-database-selected-3/#post-12728148)
 * 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](https://wordpress.org/support/users/jbdegarmo/)
 * (@jbdegarmo)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/no-database-selected-3/#post-12733898)
 * 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.

## Tags

 * [Can't select database](https://wordpress.org/support/topic-tag/cant-select-database/)
 * [MAMP](https://wordpress.org/support/topic-tag/mamp/)
 * [no database selected](https://wordpress.org/support/topic-tag/no-database-selected/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Localhost Installs](https://wordpress.org/support/forum/localhost-installs/)
 * 2 replies
 * 2 participants
 * Last reply from: [jbdegarmo](https://wordpress.org/support/users/jbdegarmo/)
 * Last activity: [6 years, 1 month ago](https://wordpress.org/support/topic/no-database-selected-3/#post-12733898)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
