-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQLSTATE[42000] [1044] Access denied for user 'xyz'@'localhost' to database 'abc' #7275
Comments
I am getting this same problem. If I upgrade to 2.11.0 or 2.11.1, I get the following error:
However, there is no such user INF to begin with. I have grepped through all my configs, and I don't see this mentioned anywhere. There is a reference to an INF key somewhere in the piwik source (I haven't looked too much into that yet). I can confirm that if I delete my piwik folder, and drop the 2.10 (or 2.9) files in, along with my config.ini.php, everything works again. For the sheer point of testing, I tried a new install with 2.11 and that also gives the same error, so this really doesn't look to be a config issue. I am also using Debian 7.8 and PHP 5.4. |
Is there any special character in your database password? |
Not in my case, not even multibyte. Just capital letters, lowercase letters and numbers - in total 23. Tested a shorter password but this did not change the cause. |
Define "special". I do have printable non-alphanumeric characters, but nothing from ascii extended or unicode. |
Moving to 2.12.0 as quite a few users seem to experience this. please comment here if you have the bug, as we haven't yet been able to reproduce it or even understand how this could happen! |
I am getting this same problem. The leading zero in the password has been removed by Piwik = wrong password. |
In my case the password does not have a leading zero but the name of the database user. So if this happens there too ... |
Here's some more insight. I setup a test machine under Kali and could not reproduce this. I think that's because of the username being used to connect to myql. On the unaffected machine, I used the user "moo". However, on the affected machine, I used a hex representation of timestamps as sql usernames. I think this name is somehow being parsed incorrectly, because when I dump the Config object after it loads the config.ini.php, the username value is of type float (totally wrong). I am still digging into this, but hopefully this helps anyone else looking narrow down the scope. |
I had a similar looking errormessage. The update had deleted all database configuration from global.ini.php. After restoring them from a backup piwik 2.11.1 ran smoothly. |
So, it looks like the issue lies in the file vendor/piwik/ini/src/IniReader.php. When this parses the config file, it first makes a call to parse_ini_string
At which point, all of the data is actually correct. But then it calls
This is where it's getting messed up. If I setup a new MySQL user called 52e666 for testing (even under Kali) it hits this line, PHP thinks I meant to specify a float and converts that string to a float. Obviously, for the username key this is very wrong (and for the password field this would equally be wrong). For now, the quick fix would be to comment out the call to Any devs want to speak up on this one? |
Thanks @unix-ninja for these tips, that's useful! cc @mnapoli |
Yes good catch @unix-ninja that's a bug in piwik/component-ini! I've opened matomo-org/component-ini#1 and will fix it today. |
Should be fixed now. |
Just wanted to confirm that I tested your change and it works for me here. Thanks! |
We still see the error after deploying 2.11.2-b3 which includes the IniReader.php fix. SQLSTATE[HY000] [1045] Access denied for user 'xxxx'@'xxxx' (using password: YES) If it's any help, the passwords starts with "00" |
Do you have the vendor folder in your piwik path? If so, what version is piwik/ini? |
@begravelsesguiden can you confirm that the username and password are correct in your |
Maybe the password starts by For example I think it makes a little sense, given in PHP a number starting with var_dump(0123);
// shows 83 |
Another solution to be sure that doesn't reproduce: only cast to int when there is no loss when it's turned back to a string afterwards… E.g. cast to int when Example of the current behavior:
|
@mnapoli good find, hopefully it's the issue experienced by @begravelsesguiden your suggestion sounds good. (and AFAIK it's no big deal if some ints are kept as strings) |
Should be good now: b7d8133 |
Just a thought (because there are likely to be additional finds on this one), maybe a better solution would just to be change the parser altogether to drop PHP's native ini parsers? This way you should be able to tell during parsing if a field is enclosed in quotes, in which case it is definitely a string, and if it's not then you apply type-finding logic. If you didn't want to do that, another (ugly) way to go about it would be to compare the raw field data after parse_ini_string runs, make a quick list of any fields encapsulated in quotes, then skip fields in the list from additional processing. |
@unix-ninja we already do that: see our project https://github.com/piwik/component-ini If using quotes, then the string stays a string whatever is in there. The problem is if the value is not inside quotes: foo = 0123 To prevent any future problem (as I said above) I changed the behavior so that values are turned into integers if and only if there is no data loss. That means that That should hopefully prevent any potential data loss with numeric values. |
@mnapoli your new IniReader.php fix solved my problem. THANK YOU! |
Just upgraded to 2.11.2 Works perfect. Thanks for working on this and to all involved! |
can you please check the DB Name and password |
After upgrading from 2.10.0 to 2.11.0 or 2.11.1 it is no longer possible for Piwiki to access the database. This issue was originally reported in the user forum.
Also trying to do a fresh install from scrap leads to this issue, no matter whether I choose the PDO/MYSQL or MYSQLi adapter. The preceeding environment check done by Piwiki runs smoothly.
No issues with 2.10.0 after rolling back to this version. An credentials issue can thus be ruled out.
Environment: PHP 5.4.36-0+deb7u3 (cli), mysql Ver 14.14 Distrib 5.5.41 (Debian 7.8)
The text was updated successfully, but these errors were encountered: