Menu

SQLSTATE[28000] [1045] Access denied

Help
Jim Knopf
2009-12-19
2013-05-30
  • Jim Knopf

    Jim Knopf - 2009-12-19

    Hello,

    I tried to install PhpGedView 4.2.2 on my webspace. When entering all the DB credentials, I get the error

    SQLSTATE  Access denied for user 'WP_DEFAULT'@'localhost' (using password: YES)

    PHP Version 5.2.10
    MySQL 5.0.32
    PDO Driver for MySQL, client library version 5.0.32

    Furthermore, php_mysql_safe_login is on (but it did not work with DB user and PW being typed in clear, either).

    The DB exists and can be accessed via PhpMyAdmin, for example. The thing is, I have PhpGedView 4.2.1 running on this webspace, and it is doing fine, as are all other scripts that use the DB server.

    But now I remember that trying to update 4.2.1 to 4.2.2 recently failed, for reasons I had no time to explore yet. But now I did the following:

    I edited the config.php by hand and entered all relevant data manually. Then PhpGedView 4.2.2 showed the same error as did the updated 4.2.1: PhpGedView showed the message that this website is not available at the moment (with the URI www.mydomain.com/install.php).

    If I had to guess, I would say it has to with PDO, but then I am not a developer, really.

    Are the changes from 4.2.1 to 4.2.2 related to any security issues? The version history I found is not conclusive in that respect, at least not for me. If no security risks are involved, I would use 4.2.1 for the moment and wait for another update.

    Any help is really appreaciated.

    Regards
    Jim

     
  • Jim Knopf

    Jim Knopf - 2009-12-19

    PS: And yes, cookies are enabled :-)

     
  • Jim Knopf

    Jim Knopf - 2009-12-21

    Hello,

    can anyone help, please?

    Regards
    Jim

     
  • Mark Hattam

    Mark Hattam - 2009-12-21

    I googled the error message you're seeing, and just about every result suggested that it's a username/password error, if not in entry then in it being used (or not).

    As you say that you can connect successfully using phpMyAdmin and you can't using PGV 4.2.2, it does rather point the finger at PDO. Do double check though that you haven't got trailing spaces or some other invisible character in the username / password. Also that the password is sufficiently long.

    My php info output on my website has similar output to what you say yours has …

        PHP Version 5.2.11
        Configure Command      '-with-pdo-mysql'
       
        PDO
        PDO drivers mysql, sqlite, sqlite2

        pdo_mysql
        PDO Driver for MySQL, client library version 5.0.86

    Have you tried creating a brand new database?

    Also have you checked that permissions on your config.php within PGV 4.2.2 is set to 777 while you're configuring, so that the items you've set are written back to it. I know you've said you've handcrafted it, which rather does mean that it has the right contents in it.

    I don't know what 4.2.3 has in store later this month …

    Mark

     
  • Mark Hattam

    Mark Hattam - 2009-12-21

    Another possible answer … have you explicitly specified the MySQL Port Number in PGV's config? If not , try entering 3306 which I know is the default anyway, but it did prove necessary on one of my other (Windoze) boxes here when going to PDO.

    Mark

     
  • Jim Knopf

    Jim Knopf - 2009-12-21

    Hello Mark,

    thank you for your reply.

    - The database was created just for this installation.
    - Permissions on config.php are set to 777.
    - User and password were entered by hand; in config.php I write "WP_DEFAULT" (without the quotes, of course), since PHP uses  phpmysqlsafe_login = on, which works fine with 4.2.1, btw.

    Maybe I just have to wait for 4.2.3, though ;-)

    Regards
    Jim

     
  • Greg Roach

    Greg Roach - 2009-12-21

    Jim, what is this WP_DEFAULT of which you speak?

    I've googled for it several times, and can't find anything.

    Nor can I find any information about php\_mysql\_safe\_login.

    > Maybe I just have to wait for 4.2.3, though

    I can't see that making any difference.

     
  • Mark Hattam

    Mark Hattam - 2009-12-21

    Also I note

        http://uk2.php.net/manual/en/ini.sect.safe-mode.php#ini.safe-mode

    Warning

    This feature has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 6.0.0. Relying on this feature is highly discouraged.

    Mark

     
  • Jim Knopf

    Jim Knopf - 2009-12-21

    Actually, the php setting I was referring to can be found here:

    http://de2.php.net/manual/en/ini.core.php#ini.sql.safe-mode

     
  • Mark Hattam

    Mark Hattam - 2009-12-21

    Well

        http://de2.php.net/manual/en/ini.core.php#ini.sql.safe-mode

    looks to be the same as the page I quoted first

        http://www.php.net/manual/en/ini.core.php#ini.sql.safe-mode

    And if you then look at the page that led me to that

        http://php.net/manual/en/function.mysql-connect.php

    and in the sections like

        username
        The username. Default value is defined by mysql.default_user.
        In SQL safe mode, this parameter is ignored and the name of the user that owns the server process is used.
       
        password
        The password. Default value is defined by mysql.default_password.
        In SQL safe mode, this parameter is ignored and empty password is used.

    So are you expecting to use an empty password, or the password that you're putting into PGV's config.php? And how does WP_DEFAULT fit in? Is that the server process name or a database user? Which returns even further up the chain here … it's a username / password issue.

    php.ini is read by Apache when Apache starts, so if you make changes to it, you need to restart Apache for the changes to be noticed. Or are you setting the SQL safe mode using .htaccess on a shared server on which you don't have control of the Apache server?

    Mark

     
  • Jim Knopf

    Jim Knopf - 2009-12-21

    Hi Mark,

    first, let me thank you for taking such an interesset in my problem.

    Apache replaces WP_DEFAULT with the correct db-user and db-password (it is not empty). I can activate this feature in my hosting enviroment, but I do not have access to Apache or even the php.ini at large, since I am on a webhosting package.

    This works for a lot of php scripts I run on this package for a lot of domains, even with PhpGedView 4.2.1, so it's got to do something with  PhpGedView 4.2.2.

    At the same time, while having activated that behavior described in the first paragraph, I can still use the clear name for db-user and db-password in scripts, but this does not work for PhpGedView 4.2.2 installation, either.

    So thanks again
    Jim

     
  • Greg Roach

    Greg Roach - 2009-12-22

    Can you disable this feature?  Try putting this line

        @ini_set('sql_safe_mode', 0);

    in your config.php file, just before the final line beginning "require once"

     
  • Jim Knopf

    Jim Knopf - 2009-12-26

    @fisharebest: This did it - thank you very much!

     

Log in to post a comment.