• Trying to set up a WordPress site. Appears to be some problem authenticating with the MySQL user/database when running the installation script at localhost/mysite/wp-admin/install.php

    (I get the now-very-familiar “Error establishing a database connection” message)

    I configured the database for it using phpMyAdmin, created a database, user, granted all:

    [it generates]

    REVOKE ALL PRIVILEGES ON * . * FROM 'mysiteuser'@'%';
    
    GRANT ALL PRIVILEGES ON * . * TO 'mysiteuser'@'%' WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;

    I also set the password with phpMyAdmin, which generates this code:
    SET PASSWORD FOR 'mysiteuser'@'%' = PASSWORD( '*****' )

    I’ve seen zillions of posts on this subject and none seem to fit my situation.

    I’ve verified that the install.php page will come up if I put the MySQL root & password in the wp-config.php file (also using “localhost” for DB_HOST)

    Checking Priveleges tab in myPhpAdmin, it displays
    mysiteuser % Yes ALL PRIVILEGES Yes Edit Privileges Edit Privileges Export Export

    and clicking “Edit Privileges” link there shows all privileges checkboxes checked.

    Thanks for help, I’ve been stumped for several days. I’m new to all this, so likely a “dumb” mistake, tho had it all set up last week.

Viewing 3 replies - 1 through 3 (of 3 total)
  • That SQL looks correct… albeit very permissive and you do not need the grant options with WordPress so you can probably uncheck that.

    If you are familiar with phpMyAdmin, I would suggest that you do the following to create a wordpress database and user.

    Drop whatever the database is that you have currently configured (if it is empty of course). Then create a new one, lets say you call it “my_wordpress_db”.

    Then manually run the following SQL Query:

    grant all privileges onmy_wordpress_db.* to 'mysiteuser'@'localhost' identified by 'mypassword';

    Then run that query and check to see if your user is listed.

    The go back and try the WordPress install again.

    Note: My query will restrict the user you have created to the database you made, and only allow it to login from the localhost, which you specified is also your web-server

    Thread Starter likeabikemike

    (@likeabikemike)

    Max, basically you’re advising starting fresh with an all-new database. I tried that, only this time I pasted in MySQL code that I templated off of code generated in the old DB before dropping it. (The code displayed substitutes asterisks for the password, so it’s necessary to edit in the actual password.)

    I created the new DB using phpMySQL, then executed the edited template code to:

    CREATE USER 'siteacct'@'lab2' IDENTIFIED BY 'sitepassword';
    
    GRANT ALL PRIVILEGES ON * . * TO 'siteacct'@'lab2' IDENTIFIED BY 'sitepassword' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
    
    GRANT ALL PRIVILEGES ON <code>lab2</code> . * TO ''@'siteacct';

    ______________________
    I think this is where I was before, except for granting ALL PRIVILEGES for the WP account only to the specific database.

    Now I’m getting the following (which I think might be different from what I got before:
    ______________________

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

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

    The user and the database both show in the phpMyAdmin, and it is listed as simply “lab2”. This seems to confirm that none of these are the problem, unless WP is looking for “siteuser_lab2”.

    …Nope. If I change the username in wp-config.php to “siteuser_lab2”, I get the previous error message:

    Error establishing a database connection

    This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at localhost. This could mean your host’s database server is down.

    Are you sure you have the correct username and password?
    Are you sure that you have typed the correct hostname?
    Are you sure that the database server is running?

    So, it seems that only granting privileges to the 1 database did make a difference, and got me closer, but not all the way there.

    Any other ideas?

    I was wondering about file permissions. WP instructions are far too casual about assumptions in this regard, not specifying what they should be. I found out through my own trial and error that everything needs to allow either the owner or group to be www-data (on Ubuntu), and set them that way (recursively). (And, actually wp-config.php group:user is set to www-data:root for me.) But if anything should be otherwise, I need to know.

    Well the SQL you are quoting is giving lots or permissions to

    a) User: siteacct on host Lab2 with password sitepassword
    b) All users on host ‘siteacct’ with no password.

    So you only need to do the following:

    a) Create a database:

    create database 'sitedb';

    b) add permissions for wordpress to that:

    grant all privileges on sitedb.* to 'siteacct'@'localhost' identified by 'sitepassword';

    This is for WordPress running on your web-server, if WordPress is not running on your web-server, then replace localhost with the IP address of your web-server. It assumes that your database is called ‘sitedb’, change that to whatever you want to call your database.

    Regarding file permissions:

    Your wordpress files should be owned by the user that the webserver, or the PHP process runs under (if you are using FCGI/FastCGI or PHP-FPM), and usually the group that the webserver and the CGI processes run under.

    Then all directories should be a maximum of 755 and all files 644.

    You can set the perms as follows:

    chown -R webuser:webgroup /public_html
    find . -type d -exec chmod 755 {} \;
    find . -type f -exec chmod 644 {} \;

    Just obviously make sure you are standing in the document root of your web server when doing that.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘MySQL authentication problem attempting wp-admin/install.php ?’ is closed to new replies.