If the problem is with database interactions, see the original answer, below.
If it's not the database connection that's the causing issue, then likely phpmyadmin is causing some global setting in the web server environment (e.g. some shared library is being reloaded with new settings, or a change to the path is causing functions to be referenced in different modules)... something is getting dynamically changed in the web server environment when phpmyadmin is executed. And that's impacting the application.
For investigating this, I suggest using phpinfo
to dump/display/capture the PHP environment settings. Temporarily add that to the script in the app, and save that snapshot.
Start phpmyadmin, or whatever is causing the problem, ...
Then run the script in the app again, and dump/display/capture the PHP environment settings, and compare that to the environment from the first snapshot.
Likely, something is going to be different, something to do with characterset conversions, e.g. causing iconv to be used instead of mbstring or vice versa, something to do with characterset conversions. Or with conflicting/overwriting HTTP headers.
I'd investigate the HTTP headers as well as the entire page source from both before and after starting phpmyadmin.
Another possibility is that its not the server at all, its wonkiness with the client web browser.
I suggest running your app in one browser, whichever browser you are using for your app.
And then start phpmyadmin from an entirely different browser. For example, use Chrome for phpmyadmin if you are using Firefox for your app script. And see if the problem appears in the app.
This will help narrow down whether issue is with the server (apache), or with the browser.
If it's the database that's causing the issue...
ORIGINAL ANSWER
Sounds to me like starting phpmyadmin is causing execution of SET GLOBAL character_set_client
, SET GLOBAL character_set_session
, and/or SET GLOBAL character_set_results
statements, changing some system variable that can be modified dynamically.
The next time the app connects to the database, the new MySQL session inherits the values of the system variables from the global settings.
Restarting mysqld fixes the problem, because the global variable is back to the original setting, or the default. And those values are what the app is expecting.
After the global setting are changed, the app isn't expecting those new settings for the MySQL connection/session.
For investigating this, I would add a query to the app to get the settings of the session variables, e.g.
SHOW VARIABLES LIKE 'character%'
and dump/display/capture the return from that.
The do whatever you do with phpmyadmin that causes the problem in the app, and then run the app again, and dump/display/capture the return from the SHOW VARIABLES LIKE 'character%'
again.
I suspect that when those are compared, there is going to be a difference.
If there is a difference, then
- figure out what is causing phpmyadmin to execute those statements, and change it so it doesn't do that any more.
That is only a partial solution, because the app is still vulnerable to any other session issuing SET GLOBAL system_variable
statements. To insulate the application:
- modify the app to specifically set the system variables for the session, e.g.
character_set_client
, character_set_connection
, character_set_results
.
The old school pattern for doing that was for the app to issue a SET NAMES
statement right after the connection is established.
But check the interface library which you are using, to see what the recommended pattern is. For example, for mysqli_, the recommendation is to not use SET NAMES
and to instead use mysqli_set_charset
http://php.net/manual/en/mysqli.set-charset.php
This is all just a guess. It's not possible to make a definitive diagnosis from the information provided.
Reference: https://dev.mysql.com/doc/refman/5.7/en/charset-connection.html