Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Commit

Permalink
tests: document how to set up 2 MySQL servers
Browse files Browse the repository at this point in the history
  • Loading branch information
kennytm committed Feb 26, 2020
1 parent 25e2bae commit 89c68f7
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,54 @@

## Running

### Prepare MySQL servers

You can run multiple MySQL servers by:

1. Initialize two data directories.

```sh
mysqld --initialize-insecure --datadir=mysqld1
mysqld --initialize-insecure --datadir=mysqld2
```

2. Create a configuration file

```ini
[mysqld_multi]
user = root
password =
tcp-ip
verbose
[mysqld1]
port = 3306
datadir = /absolute/path/to/c/mysqld1
socket = /absolute/path/to/c/mysqld1/mysql.sock
pid-file = /absolute/path/to/c/mysqld1/mysql.pid
secure-file-priv = NULL
[mysqld2]
port = 3306
datadir = /absolute/path/to/c/mysqld2
socket = /absolute/path/to/c/mysqld2/mysql.sock
pid-file = /absolute/path/to/c/mysqld2/mysql.pid
secure-file-priv = NULL
```

then start the servers using [`mysqld_multi`](https://dev.mysql.com/doc/refman/8.0/en/mysqld-multi.html)

```sh
mysqld_multi --defaults-file=my.cnf start 1,2
```

3. Verify the connections work

```sh
mysql -u root -h 127.0.0.1 -P 3306 -e 'select version();'
mysql -u root -h 127.0.0.1 -P 3307 -e 'select version();'
```

### Unit Test

1. Setup a MySQL server with binlog enabled first, export proper environment variable `MYSQL_HOST`, `MYSQL_PORT`, `MYSQL_USER`, `MYSQL_PSWD`, default is `127.0.0.1`, `3306`, `root` and empty password.
Expand Down

0 comments on commit 89c68f7

Please sign in to comment.