By fernando | April 2, 2009

Using MySQL sandbox for testing

MySQL Sandbox is a great tool for quickly deploying test MySQL instances, particularly if your daily work involves diagnosing problems across multiple MySQL versions.

Once you’ve downloaded it, it needs no installation. Just have a few MySQL binary releases at hand, and begin creating sandboxes in just a few seconds:

./make_sandbox mysql-5.0.77-linux-x86_64-glibc23.tar.gz

or

./make_sandbox mysql-5.1.32-linux-x86_64-glibc23.tar.gz

Pretty simple, huh?

Suppose you have a parallel build around, say, 5.0.77-percona-highperf. The default syntax won’t work if you’ve already created a 5.0.77 sandbox, since Sandbox will use ’5.0.77′ as the sandbox dir. In this case, you’ll need to manually specify a directory name:

./make_sandbox mysql-5.0.77-percona-highperf-b13.tar.gz -d msb_percona_5_0_77

Fortunately, all Sandbox commands have a –help option that provide helpful screens to let you know how you can modify their default behavior. In this particular case, you’ll actually need to access the help for low_level_make_sandbox, since that’s the script that’s eventually called.

Once a sandbox is created, using it is real simple. Just cd to it’s directory (by default, $HOME/sandboxes/$SANDBOXDIR) and issue one of the following commands:

  • ./start
  • ./stop
  • ./restart
  • ./use (this invokes the sandbox’s mysql client with appropriate parameters. you can append your own parameters too, i.e., a database name)
  • ./clear (stops the server and removes everything from the data directory, leaving you ready to start from scratch)

It even includes an option to create replication sandboxes, with a master node and two slaves. This is by default, but you can also create multiple sandboxes of the same version and configure replication yourself.

Here’s an example:

./make_replication_sandbox mysql-5.0.77-linux-x86_64-glibc23.tar.gz

So there it is, once again, download it and start having fun!

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • MisterWong
  • Y!GG
  • Webnews
  • Digg
  • del.icio.us
  • StumbleUpon
  • Reddit
  • email
  • Facebook
  • LinkedIn
  • Technorati

Related posts:

  1. High Availability MySQL Cookbook review High Availability MySQL Cookbook (Alex Davies, Packt Publishing) presents different...
  2. Using MySQL Proxy to benchmark query performance By transparently sitting between client and server on each request,...
  3. Indexing text columns in MySQL This time, I’m talking about indexes for string typed columns....
  4. Updated mysql-proxy benchmarking script (for proxy 0.7) My previous post contained a lua script for MySQL proxy...
  5. MySQL Certification self study I’m taking the MySQL Certification exams soon, and while I’d...

Related posts brought to you by Yet Another Related Posts Plugin.