Page 1 of 1

Error encountered opening MySQL connection

Posted: Mon 31 Jan 2022 6:39 am
by flort
Hi,

I decided to start utilizing an SQL Database but receive a "Connect timeout expired" error when trying to create the database tables. I assume my server details are all correct otherwise I should get a login error rather than a timeout error. This may be purely a webhosting issue as I use a free webhosting service so don't expect my account would get much priority with connection requests. I have also tried using the ExportToMySQL tool and get the same error.

Does anyone have any suggestions as to what else I might try or is there a way to increase the length of time it tries to connect before timing out?

Regards,
Trevor

Re: Error encountered opening MySQL connection

Posted: Mon 31 Jan 2022 2:45 pm
by mcrossley
By default MySQL does not allow remote logins for users, you have to specify that (either from a specific host or IP, or * from anywhere) when creating the user account, did you do that?

Re: Error encountered opening MySQL connection

Posted: Mon 31 Jan 2022 10:40 pm
by flort
Hi Mark,

Thanks for the reply. I was unaware that remote logins were not allowed by default. Upon investigation I have found that the free webhosting plan does not allow configuration of remote SQL.

So what I have done is setup my RPi as a webserver for use within my local network. Everything is working fine and database is updating but I do receive the following error when I view the database through phpMyAdmin -
error.jpg
Have I done something wrong when setting this up? I created the table using the function in Cumulus SQL settings and populated the table using the ExportToMySQL tool.

Regards,
Trevor

Re: Error encountered opening MySQL connection

Posted: Tue 01 Feb 2022 10:08 am
by mcrossley
I have found setting up phpMyAdmin a bit of a struggle at times. Sometimes it has setup without any issues at all, the odd time I have spent ages trying to get it working properly.

Can you query the tables OK from the MySQL command line?

Re: Error encountered opening MySQL connection

Posted: Tue 01 Feb 2022 10:38 am
by flort
Hi Mark,

Everything seems to be working fine. I even have a couple of web pages talking to the database without any issues. So should I just ignore the errors or try deleting the table and creating it again?

Regards,
Trevor

Re: Error encountered opening MySQL connection

Posted: Tue 01 Feb 2022 4:53 pm
by sfws
flort wrote: Mon 31 Jan 2022 10:40 pm I do receive the following error when I view the database through phpMyAdmin
That is a standard php error message for php 7.2 upwards which says that use of "count()" in a PHP script is incompatible with the php version you are using. It has nothing to do with database tables, don't delete table and create it again, that is a waste of time as it will not solve anything!

In other words it implies you are using an extremely old version of a phpmyadmin script written using php syntax for php 5.4 to 7.1 era.

Use latest phpmyadmin, i.e. version 5.1.1, (as that works from php 7.2 up to current stable 8.1.x) - see here for a good explanation of how to upgrade and you will be problem free.

Re: Error encountered opening MySQL connection

Posted: Tue 01 Feb 2022 11:29 pm
by flort
Thanks. Upgraded phpmyadmin as suggested and no more errors.

Regards,
Trevor

Re: Error encountered opening MySQL connection

Posted: Wed 02 Feb 2022 10:06 am
by mcrossley
Good spot @sfws. :thumbsup: