• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Resolved (bug ?) mysql_pconnect() fails if password contains $

AdrianC

Basic Pleskian
Plesk 17.5.3 on Centos.
I just noticed that if my database password contains "$" I get "access denied for user@localhost" error in PHP.
It works to connect just fine from other database tools, but in PHP I get db connection error.
I think also Plesk uses "$" when generating a random password.
You might want to fix that because for us it can be a pain to debug.
 
This is no bug in plesk, but normal php string behaviour.
$ is interpreted as the start of a variable in php. So when that is in a password, you need to escape it.

$_DB["password"] = "mypas$word"; translates for php in mypas + the content of the variable $word, as $word is not initialized or filled, it will be empty and the password you pass to mysql will be in this case: mypas .... resulting in an error.

it should be

$_DB['password'] = 'mypas$word'; (single quotes)
or
$_DB['password'] = "mypas\$word"; (escape the $)

Personally i find using single quotes less error prone.

regards
Jan
 
Well that's embarrasing, I was fully aware of all the above but I didn't realise it :)
Thanks.

// Maybe it would still be good for Plesk to avoid generating passwords containing $, as a precaution.
 
Back
Top