MySql: June 2009 Archives

MySql ServerName.Log file size

|
A quick and dirty hack (written in C#) to solve the issue of MySql query log files getting huuuge:

System.ServiceProcess.ServiceController sc = new ServiceController("mysql", "servername");
sc.Stop();
Console.WriteLine("Stopping");
sc.WaitForStatus(ServiceControllerStatus.Stopped, new TimeSpan(0, 0, 30));
Console.WriteLine("Stopped");
System.IO.File.Delete(@"\\servername\C$\Program Files\MySQL\MySQL Server 5.0\data\ServerName.log");
Console.WriteLine("Starting");
sc.Start();
sc.WaitForStatus(ServiceControllerStatus.Running, new TimeSpan(0, 0, 30));
Console.WriteLine("Started");
I have this compiled into a CruiseControl task that runs at 7am every day, no more massive log files and a lot easier than trying to decipher the MySql documentation. Plus, I've got some other odds and ends of maintenance that I've shoe-horned in. Not necessarily elegant, but it works!

MySql - Running a complex script using the .net Connector

|
[The solution was discovered via this entry in the mysql.com forums]

I your MySql script contains code like

"/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;"
You'll need to add "Allow User Variables=true" to your connection string. This can be achieved by manually adding it to the string, or, if using a MySqlConnectionStringBuilder, something similar to the following:

var builder = new MySqlConnectionStringBuilder
{
     Database = database,
     Server = Server,
     Password = Password,
     UserID = Username
};
builder.Add("Allow User Variables", true);
Make sure you're using at least version 5.2.6 of the MySql Connector/Net though! The forum posting states that it works with 5.2.2, but it didn't work with the copy of 5.2.2 I hav, but did with 5.2.6.

Other useful links from the forums:
Re: How do i run a *.sql script from my c# environment?

About this Archive

This page is a archive of entries in the MySql category from June 2009.

MySql: May 2009 is the previous archive.

Find recent content on the main index or look in the archives to find all content.

MySql: June 2009: Monthly Archives

Powered by Movable Type 5.04