Create real MySQL server instance for testing
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 31 commits behind lestrrat-go:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Build Status

Create real MySQL server instance for testing

To install, simply issue a go get:

go get

By default importing will import package mysqltest

import (

mysqld, err := mysqltest.NewMysqld(nil)
if err != nil {
   log.Fatalf("Failed to start mysqld: %s", err)
defer mysqld.Stop()

db, err := sql.Open("mysql", mysqld.Datasource("test", "", "", 0))
// Now use db, which is connected to a mysql db

go-test-mysqld is a port of Test::mysqld

When you create a new struct via NewMysqld() a new mysqld instance is automatically setup and launched. Don't forget to call Stop() on this struct to stop the launched mysqld

If you want to customize the configuration, create a new config and set each field on the struct:

config := mysqltest.NewConfig()
config.SkipNetworking = false
config.Port = 13306

// Starts mysqld listening on port 13306
mysqld, _ := mysqltest.NewMysqld(config)


  • CopyDataFrom is not implemented.