Archive for the 'MySQL' Category

Virtualmin MySQL Backup using strftime

If you are trying to make MySQL backups in Virtualmin that create individual time-based folders like

12-11-2009
13-11-2009

You can turn on strftime substitution in the module config for MySQL in Webmin. This is off by default.

Here is the screen shot:

Capture

Cheers and happy new year to everyone :)

MySQL prompt Display all possibilities when running stored procedures

If you keep getting the Display all <insert number> possibiilities prompt when you are pasting queries into your mysql shell, it will cause your queries to fail. This is due to the use of the tab character that triggers the behaviour. To resolve this, convert the tab characters in your statement to spaces.

Most SQL management software like EMS allows you to use spaces instead of tabs. They usually fall under the options.

MySQL Error/Warning: Too Many Connections

This post is to help server administrators who are managing MySQL servers. If you run into users complaining about error regarding too many connections to MySQL, do check the script that runs and make sure that connections are closed.

For example if you open a connection in php using:

$mysqli = new MySQLI(’localhost’,'root’,'password’,'dBName’);

At the end of the script, do remember to close the connection by calling:

mysqli_close($mysqli);

To verify that things are working, SSH into your system,

1) go into MySQL command line by typing something like mysqld -u root -p
2) type in “show processlist;
3) take note of the processes already running
4) Run the php (or .net or whichever script)
5) type in “show processlist;” again a while after the script has finished executing
6) If you see new processes being in Sleep status then the script is not closing the connections properly (unless this is a deliberate action by the developer to re-use a connection, but this usually should not happen)
7) You can manually kill the process by typing “kill <process id>;” (You can see the process id in the process list table

So if the script is not closing connections, the script should be checked to ensure that they are closed and run through the test above again. This will assist in the server’s performance as well.

Note: The default max_connections, which govern the maximum number of connections to the MySQL server instance is 100, you can increase this, but it is not a good solution compared to the above which addresses the root of the issue. MySQL has a suggestion that dynamically increases the max_connections which works as well but it has to be dependent on the scenario you are facing.