Can't connect to MySQL: port missing


Just a message to help someone who have the same issue than me.

I moved my website to another hosting and it can't connect to the database. I get the error:
SQLSTATE[HY000] [2003] Can't connect to MySQL server

After some search, I found that the MySql port is not the default.
So I changed manualy my config file "database.php" to set the port:
'server' => 'newdbserver',
'port' => '34923', (<-added line)
( or, if you want: 'server' => 'newdbserver;port=34923' )

Concrete5 improvement:
Perhaps it's an improvement for the installation of C5: add a field for the port and store it in the config file.


View Replies:
exchangecore replied on at Permalink Reply
Just out of curiosity, did you try adding the port to the server name?

So your "server" would actually be "newdbserver:34923" possibly? This is a pretty common syntax for hostnames, and I wonder if it would have taken care of your issue without having to invent a workaround.
aruben replied on at Permalink Reply
Yes I try, but I get the error:
SQLSTATE[HY000] [2005] Unknown MySQL server host 'newdbserver:34923'

So, I simply add the new port line in the config file.
I also see in the file "\concrete\src\Database\Driver\PDOMySqlConcrete5\Driver.php" that the port is added with ";port=34923;" instead of ":34923".