N00b MySQL/WP config question

  • Posted September 17, 2012

Hi guys,

It’s been years since I worked in web hosting - I’m sure the answer is super easy, but it’s late and my brain won’t grok anymore tonight:

Ok, so (obvious strings have been changed to protect, well, me):


CREATE USER my_wp_db_un@localhost;

SET PASSWORD FOR my_wp_db_un@localhost= PASSWORD(“mycleverwppw”);

GRANT ALL PRIVILEGES ON wordpress.* TO my_wp_db_un@localhost IDENTIFIED BY ‘password’;

(or is it)

GRANT ALL PRIVILEGES ON wordpress.* TO my_wp_db_un@localhost IDENTIFIED BY ‘mycleverwppw’;

(I’ve tried it both ways)


sudo nano ~/wordpress/wp-config.php

// ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define(‘DB_NAME’, ‘my_wp_db’);

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

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

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

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

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

Do you guys see any notable syntax errors? Are there logs I could look at to help me? Any advice is welcome - thank you!


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

To test whether or not the connection to the database works and has the correct privileges you can do: <br> <br># mysql -u username -p <br>mysql> use databasename; <br>mysql> create table my_test; <br>mysql> drop table my_test; <br> <br>If you get an error running the mysql command that means your username and password aren’t right. <br> <br>If you get an error on the use statement that means the user that you accessed mysql with doesn’t have any privileges on the database. <br> <br>If you get an error on the create and the drop that means your user doesn’t have create privileges which means wordpress will not install. <br> <br>A simple syntax for creating a user, granting privileges, and setting a password in one command is: <br>mysql> GRANT ALL ON databasename.* to username@localhost identified by ‘password’; <br> <br>Based on your error it seems that the user/pass allows you to connect but that the user doesn’t have privileges. <br> <br>So running that GRANT command should fix things for you.

Awesome, glad to hear it!

Wheee! Tried it a couple of times using my existing un - no dice. Went ahead and made a brand new un/pw according to the GRANT command you posted - refreshed the wpconfig file and voila! Thank you so much!