Library for working with MySQL server instances from within a Go program. Note that this is not a MySQL client program; it is not used to connect to MySQL servers. You have to use some other library for that.
You can use the go get
command to download and install the package
from from github.com:
go get github.com/mkindahl/mysqld
The library allow you to create and bootstrap new scatch instances of MySQL servers, run some quick tests or programs, and then remove the servers. It also allow you to manage different versions of servers in the same setup so that you can test, for example, replication between different versions of servers or run test scripts against different versions of servers to check how they behave.
The package contains an API to work with distributions and servers as well as a command-line utility using this API. You will see the command-line interface here; if you're interested in the API, you should look into the package documentation.
To work with a set of servers, you need to create a stable where all the distributions and servers will reside.
gomysql init .
The information will be stored under the .stable
directory in the
provided directory.
Once you have a stable set up, you can add distributions to it. Each distribution is installed from a binary distribution of the MySQL server. If you want to install your own version, you need to build a binary distribution from the source tree and add it to the stable using the command:
gomysql add dist mysql-5.1.71-linux-x86_64-glibc23.tar.gz
If the distribution is an archive, the binary distribution will be copied into the stable directory, but if a directory is given, a soft link will be created in the stable.
Servers are created from distributions and you can create as many
servers as you like. When creating a server, a distribution name can
be provided using the -dist
flag. However, since distribution names
can be quite long, it is sufficient to provide a unambigous substring
of the distribution name.
gomysql server add -dist=5.1.71 my_server
If no distribution is provided, a match of all distributions is done, which means that if you have a single distribution, it will pick that one.
gomysql server add my_server
Once you are done with the server, you can remove it using:
gomysql server remove my_server
If you want to work with the code, there are a few suggestions in this section.
Some tests require a distribution to execute. For those tests, a
distribution can be provided using the -dist
flag. For example, to
run the tests using mysql-5.6.14-linux-glibc2.5-i686.tar.gz
, provide
it with the -dist
flag. Some tests require an expected version, so
to provide an expected version of the server to be found in the
distribution, use the -version
flag:
go test -dist=mysql-5.6.14-linux-glibc2.5-i686.tar.gz -version=5.6.14
Tests that require a distribution or an expected version to work will be skipped if no distribution or expected version is provided.
This package was written by Mats Kindahl (mats.kindahl@oracle.com).
This software is released under the version 2 of the GNU General Public License.
License information can be found in the LICENSE.txt file.