Bug #29927 no database selected - sometimes
Submitted: 20 Jul 2007 10:36 Modified: 26 Jul 2007 7:06
Reporter: Mauro Bernardini Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Errors Severity:S1 (Critical)
Version:5.2.1 OS:Windows (Windows 2000)
Assigned to: CPU Architecture:Any
Tags: no database selected - sometimes

[20 Jul 2007 10:36] Mauro Bernardini
Description:
I have the problem with "no database selected" but it appears sometimes. Great part of access with the web site tu the db MySQL works correctly. But sometimes appears this error message. It needs to refresh page or turn back and access again to the same page and, then, it works. May the my.ini configuration have some problem?
The system works on server with Windows 2000. DB is no so big and the max access number is about 100. Thanks 

How to repeat:
when launch the PHP string:

$conn = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);
[20 Jul 2007 11:15] Sveta Smirnova
Thank you for the report.

I see you use connect string $conn = mysql_pconnect($hostname, $username, $password) which does not contain default database. Please check your application if mysql_select_db of mysql_query('USE db') were issued before you run a query which needs a database to be selected.

If you are sure in above create PHP script which we can run in our environment and repeat the error.
[20 Jul 2007 11:29] Mauro Bernardini
Sorry i forgot to include an important string:

mysql_select_db($database) or die("Non riesco a selezionare il db");

But as i wrote before the problem appears sporadically. The great part of times it connects correctly

Thank again
[20 Jul 2007 11:39] Sveta Smirnova
Thank you for the feedback.

Are you sure mysql_select_db($database) was running before every query which needs default database? To check it replace mysql_pconnect with mysql_connect and examine how MySQL server will behave.

Also version 5.2.1 looks like version of PHP. Which version of MySQL do you use?
[20 Jul 2007 12:47] Mauro Bernardini
I already replaced "mysql_pconnect" with "mysql_connect" ma it was the same thing.

My configuration is PHP 5.2.1 - Apache 2.2.4 - MySQL 5.0.22.

Yesterday I discovered in server log a problem relative to mysql like this:
Warning EventID:100 - Changed limits: max_open_files: 2048 max_connections:800 table_cache:619.

...then i changed this values in my.ini with:
max_connections=100;
table_cache=620

...and in this way it seems resolved because now I don't found anymore error logs and program run regularly. What other can i configured? Because i don'find "max_open_files". Thanks
[20 Jul 2007 13:48] MySQL Verification Team
Thank you for the bug report. Could you please upgrade to latest released
version 5.0.45 since your reported version is pretty older. Thanks in
advance.
[20 Jul 2007 14:07] Mauro Bernardini
I'll do it immediatly - Many thanks
[23 Jul 2007 9:21] Sveta Smirnova
Status cahnged, because feedback is needed.
[23 Jul 2007 11:12] Mauro Bernardini
Sorry but I didn't understand the "Status changed". What should I do exactly? Where I have to subscribe feedback? Please help me - thanks.
[23 Jul 2007 11:21] Sveta Smirnova
You should upgrade MySQL to version 5.0.45 and try with it.
[23 Jul 2007 11:43] MySQL Verification Team
Upgrade and test, then comment here the result.
[23 Jul 2007 13:22] Mauro Bernardini
Ok I upgraded and resolved succesfully (no more problems matched) but, I suppose, the problem was not depending by the upgrade. I found a wrong configuration on MY.INI file, as i wrote on 20 Jul 07 14:47. Thanks
[26 Jul 2007 7:06] Sveta Smirnova
Thank you for the feedback.

Report closed as "Can't repeat" because last comment