|
7 | 7 |
|
8 | 8 | if [ ! -z "${DB}" ]; then
|
9 | 9 | # disable existing database server in case of accidential connection
|
10 |
| - mysql -u root -e 'drop user travis@localhost; drop user root@localhost; drop user travis; create user super@localhost; grant all on *.* to super@localhost with grant option' |
11 |
| - mysql -u super -e 'drop user root' |
12 |
| - |
13 |
| - F=mysql-${DB}-linux-glibc2.12-x86_64 |
14 |
| - mkdir -p ${HOME}/mysql |
15 |
| - P=${HOME}/mysql/${F} |
16 |
| - if [ ! -d "${P}" ]; then |
17 |
| - wget https://cdn.mysql.com//Downloads/MySQL-${DB%.*}/${F}.tar.gz -O - | tar -zxf - --directory=${HOME}/mysql |
18 |
| - fi |
19 |
| - if [ -f "${P}"/my.cnf ]; then |
20 |
| - O="--defaults-file=${P}/my.cnf" |
21 |
| - fi |
22 |
| - if [ -x "${P}"/scripts/mysql_install_db ]; then |
23 |
| - I=${P}/scripts/mysql_install_db |
24 |
| - O="--defaults-file=${P}/my.cnf" |
25 |
| - else |
26 |
| - I=${P}/bin/mysqld |
27 |
| - IO=" --initialize " |
28 |
| - O="--no-defaults " |
29 |
| - fi |
30 |
| - ${I} ${O} ${IO} --basedir=${P} --datadir=${HOME}/db-"${DB}" --log-error=/tmp/mysql.err |
31 |
| - PWLINE=$(grep 'A temporary password is generated for root@localhost:' /tmp/mysql.err) |
32 |
| - PASSWD=${PWLINE##* } |
33 |
| - if [ -x ${P}/bin/mysql_ssl_rsa_setup ]; then |
34 |
| - ${P}/bin/mysql_ssl_rsa_setup --datadir=${HOME}/db-"${DB}" |
35 |
| - fi |
36 |
| - # sha256 password auth keys: |
37 |
| - openssl genrsa -out "${P}"/private_key.pem 2048 |
38 |
| - openssl rsa -in "${P}"/private_key.pem -pubout -out "${P}"/public_key.pem |
39 |
| - ${P}/bin/mysqld_safe ${O} --ledir=/ --mysqld=${P}/bin/mysqld --datadir=${HOME}/db-${DB} --socket=/tmp/mysql.sock --port 3307 --innodb-buffer-pool-size=200M --lc-messages-dir=${P}/share --plugin-dir=${P}/lib/plugin/ --log-error=/tmp/mysql.err & |
40 |
| - while [ ! -S /tmp/mysql.sock ]; do |
41 |
| - sleep 3 |
42 |
| - tail /tmp/mysql.err |
| 10 | + sudo service mysql stop |
| 11 | + |
| 12 | + docker pull mysql:${DB} |
| 13 | + docker run -it --name=mysqld -d -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -p 3306:3306 mysql:${DB} |
| 14 | + sleep 10 |
| 15 | + |
| 16 | + while : |
| 17 | + do |
| 18 | + sleep 5 |
| 19 | + mysql -uroot -h 127.0.0.1 -P 3306 -e 'select version()' |
| 20 | + if [ $? = 0 ]; then |
| 21 | + break |
| 22 | + fi |
| 23 | + echo "server logs" |
| 24 | + docker logs --tail 5 mysqld |
43 | 25 | done
|
44 |
| - tail /tmp/mysql.err |
45 |
| - if [ ! -z "${PASSWD}" ]; then |
46 |
| - ${P}/bin/mysql -S /tmp/mysql.sock -u root -p"${PASSWD}" --connect-expired-password -e "SET PASSWORD = PASSWORD('')" |
47 |
| - fi |
48 |
| - mysql -S /tmp/mysql.sock -u root -e "create user ${USER}@localhost; create user ${USER}@'%'; grant all on *.* to ${USER}@localhost WITH GRANT OPTION;grant all on *.* to ${USER}@'%' WITH GRANT OPTION;" |
49 |
| - sed -e 's/3306/3307/g' -e 's:/var/run/mysqld/mysqld.sock:/tmp/mysql.sock:g' .travis/database.json > pymysql/tests/databases.json |
50 |
| - echo -e "[client]\nsocket = /tmp/mysql.sock\n" > "${HOME}"/.my.cnf |
| 26 | + |
| 27 | + echo -e "[client]\nhost = 127.0.0.1\n" > "${HOME}"/.my.cnf |
| 28 | + |
| 29 | + mysql -e 'select VERSION()' |
| 30 | + mysql -uroot -e 'create database test1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;' |
| 31 | + mysql -uroot -e 'create database test2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;' |
| 32 | + |
| 33 | + mysql -u root -e "create user test2 identified by 'some password'; grant all on test2.* to test2;" |
| 34 | + mysql -u root -e "create user test2@localhost identified by 'some password'; grant all on test2.* to test2@localhost;" |
| 35 | + |
| 36 | + cp .travis/docker.json pymysql/tests/databases.json |
51 | 37 | else
|
| 38 | + cat ~/.my.cnf |
| 39 | + |
| 40 | + mysql -e 'select VERSION()' |
| 41 | + mysql -e 'create database test1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;' |
| 42 | + mysql -e 'create database test2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;' |
| 43 | + |
| 44 | + mysql -u root -e "create user test2 identified by 'some password'; grant all on test2.* to test2;" |
| 45 | + mysql -u root -e "create user test2@localhost identified by 'some password'; grant all on test2.* to test2@localhost;" |
| 46 | + |
52 | 47 | cp .travis/database.json pymysql/tests/databases.json
|
53 | 48 | fi
|
0 commit comments