• Hi guys, I am trying to set up wordpress locally but am getting the following

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

    Are you sure it exists?
    Does the user root have permission to use the wp database?
    On some systems the name of your database is prefixed with your username, so it would be like username_wp. 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.”

    This is my config file
    define(‘DB_NAME’, ‘wp’);

    /** MySQL database username */
    define(‘DB_USER’, ‘root’);

    /** MySQL database password */
    define(‘DB_PASSWORD’, ”);

    /** MySQL hostname */
    define(‘DB_HOST’, ‘localhost’);

    /** Database Charset to use in creating database tables. */
    define(‘DB_CHARSET’, ‘utf8’);

    I have created a database in phpmyadmin with exactly the name of wp and the root user has privleges and access to this database so I’m not sure the problem is

Viewing 15 replies - 1 through 15 (of 24 total)
  • you should create a user in DB, add user to your DB, and give all permissions.
    then add “wp_username” format or just username.

    also, you might have the port blocked but i think is user as stated above.

    Thread Starter a22mu

    (@a22mu)

    I created a user named “root2” set a password and gave the user all permissions to the database and then used in the config file but it gives me the same error.

    Thread Starter a22mu

    (@a22mu)

    I can install wordpress using the “test” database which was created by default by PHPMyAdmin. Can I just do it on this or will this be a problem somewhere in the future?

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Did you actually go into phpMyAdmin and create a database named “wp”?

    WordPress does not create the database for you, it only creates the necessary tables and things. You have to create the actual database yourself.

    Thread Starter a22mu

    (@a22mu)

    Yes I went in and did that, as I said it is working with the “test” database which was there after installing WAMP

    Thread Starter a22mu

    (@a22mu)

    I still need help with this because if I want to make another site (not multisite) then I wouldn’t be able to do this as I not able to link the database for whatever reason

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    No, don’t use the test database. You have to create a new database and use that.

    Thread Starter a22mu

    (@a22mu)

    As I have said multiple times I have set up a new database and tried that. Why respond if you aren’t going to read the problem?

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    I have read the problem, but you’re not giving us enough information to help you solve it.

    You have to set the define('DB_NAME', 'wp'); line to the name of the empty database that you just created. Alternatively, rename the wp-config.php file and let the setup process create that file for you. During that process, you can simply type the db name into there and it’ll try it.

    Basically, you’re not making a lot of sense here. If you created the database, then you can connect to it using something like phpMyAdmin, right? So, all you have to do is to put in the correct information to the wp-config.php file.

    This error message doesn’t really have any ambiguity to it:

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

    It’s straightforward and means exactly what it says. The username and password are correct, but the DB_NAME is not. Either you didn’t create a database with that name, or you did it using a different username and password.

    Since this is a local AMP install, the username and password is always root and blank. I assume you created the DB using phpMyAdmin. So, there’s not a whole lot of room for error here. You’re doing something wrong, but I can’t tell you what it is because I can’t see you doing it.

    Thread Starter a22mu

    (@a22mu)

    Samuel, therein lies in the problem. There is no ambiguity to it at all.

    So then when I do the things that you suggest (which I have done multiple times) such as changing the config file to have the created database name, or deleting the config file and putting in the correct name through the other method then why isn’t it working?

    I don’t see where the problem is in such a simple process.

    @am22mu I hope this helps. I will explain how I setup WP locally in just a few steps.

    First I would like to say that I understand your frustration but just for the record Samuel is considered one of the most knowledgeable people when it comes to WordPress and I don’t mean this subjectively. It’s a fact. These forums are operated on a volunteer basis only and whether he understood your problem or not, I’m sure with the proper info he could solve it.

    I use XAMPP. Regardless, I create a blank DB in phpMyAdmin. I then copy WordPress files to a folder such as htdocs/(domain-name). I then access the site via localhost/(domain-name) in my browser and let WordPress create the wp-config file. I simply enter my DB name, root as user, and leave PW blank since we are not worried about security on our local environment.

    If you continue to have issues, please respond and I or somebody else will try to help you ??

    @keithdriscoll @am22mu
    Hi, I dont see it and no one has informed that you should have defined a table prefix and this will cause a connection issue, again verify in your config that you have indeed defined a table prefix as such

    $table_prefix = ‘wp_’;

    you can view a sample config file here
    https://generatewp.com/wp-config/

    Thread Starter a22mu

    (@a22mu)

    I have already done that all, I have screenshots of it, how can I post them here?

    Thread Starter a22mu

    (@a22mu)

    confused?
    in your notes above you state
    define(‘DB_NAME’, ‘wp’);

    but in the image shots it states
    define(‘DB_NAME’, ‘lep’);

    which one are u trying to connect to?

Viewing 15 replies - 1 through 15 (of 24 total)
  • The topic ‘Can't select database’ is closed to new replies.