Signed-off-by: Luan Shengde shdluan@163.com --- tests/mysql-8-0-20 | 73 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100755 tests/mysql-8-0-20
diff --git a/tests/mysql-8-0-20 b/tests/mysql-8-0-20 new file mode 100755 index 000000000..ebc7c0e90 --- /dev/null +++ b/tests/mysql-8-0-20 @@ -0,0 +1,73 @@ +#!/bin/sh +# - data_dev +# mysql_user +# mysql_host +# mysql_port +# mysql_db +# mysql_password +. $LKP_SRC/lib/common.sh + +: "${mysql_user:=root}" +: "${mysql_host:=127.0.0.1}" +: "${mysql_port:=3306}" +: "${mysql_db:=sysbench_test}" +: "${mysql_password:=mysql_password}" + +create_basedir() +{ + mkdir -p /data + mkfs.xfs -f /dev/"$data_dev" + mount /dev/"$data_dev" /data + + mkdir -p /data/mysql/{data,share,tmp,run,log} + + useradd mysql + touch /data/mysql/log/mysql.log + chown -R mysql:mysql /data + chown -R mysql:mysql /data/mysql/log/mysql.log +} + +configure_mysql() +{ + if [ ! -f $mysqld ] || [ ! -f $mysql ] || [ ! -f $mysql_server ]; then + echo "mysql is not installed!" && exit 1 + fi + + "$mysqld" --user=mysql --datadir=/data/mysql/data --basedir=/data/mysql --initialize --port="$mysql_port" + sleep 10 + + "$mysql_server" start + sleep 10 + + "$mysql" -u "$mysql_user" -e "flush privileges; use mysql; alter user 'root'@'localhost' identified by '$mysql_password'; flush privileges;" + sed -i '/^skip-grant-tables/d' /etc/my.cnf + "$mysql_server" restart + sleep 10 +} + +create_database() +{ + "$mysql" -u "$mysql_user" -p"$mysql_password" -e "use mysql; update user set host ='%' where user='root'; flush privileges;" + "$mysql" -u "$mysql_user" -p"$mysql_password" -e "create database $mysql_db;" + "$mysql_server" stop + sleep 10 +} + +start_mysql() +{ + "$mysqld" --defaults-file=/etc/my.cnf --port="$mysql_port" + sleep 20 +} + +main() +{ + local mysql="/usr/local/mysql/bin/mysql" + local mysqld="/usr/local/mysql/bin/mysqld" + local mysql_server="/usr/local/mysql/support-files/mysql.server" + + create_basedir + configure_mysql + create_database + start_mysql +} +main
pls ignore this mail
On Fri, Apr 23, 2021 at 09:46:27AM +0800, Luan Shengde wrote:
Signed-off-by: Luan Shengde shdluan@163.com
tests/mysql-8-0-20 | 73 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100755 tests/mysql-8-0-20
diff --git a/tests/mysql-8-0-20 b/tests/mysql-8-0-20 new file mode 100755 index 000000000..ebc7c0e90 --- /dev/null +++ b/tests/mysql-8-0-20 @@ -0,0 +1,73 @@ +#!/bin/sh +# - data_dev +# mysql_user +# mysql_host +# mysql_port +# mysql_db +# mysql_password +. $LKP_SRC/lib/common.sh
+: "${mysql_user:=root}" +: "${mysql_host:=127.0.0.1}" +: "${mysql_port:=3306}" +: "${mysql_db:=sysbench_test}" +: "${mysql_password:=mysql_password}"
+create_basedir() +{
- mkdir -p /data
- mkfs.xfs -f /dev/"$data_dev"
- mount /dev/"$data_dev" /data
- mkdir -p /data/mysql/{data,share,tmp,run,log}
- useradd mysql
- touch /data/mysql/log/mysql.log
- chown -R mysql:mysql /data
- chown -R mysql:mysql /data/mysql/log/mysql.log
+}
+configure_mysql() +{
- if [ ! -f $mysqld ] || [ ! -f $mysql ] || [ ! -f $mysql_server ]; then
echo "mysql is not installed!" && exit 1
- fi
- "$mysqld" --user=mysql --datadir=/data/mysql/data --basedir=/data/mysql --initialize --port="$mysql_port"
- sleep 10
- "$mysql_server" start
- sleep 10
- "$mysql" -u "$mysql_user" -e "flush privileges; use mysql; alter user 'root'@'localhost' identified by '$mysql_password'; flush privileges;"
- sed -i '/^skip-grant-tables/d' /etc/my.cnf
- "$mysql_server" restart
- sleep 10
+}
+create_database() +{
- "$mysql" -u "$mysql_user" -p"$mysql_password" -e "use mysql; update user set host ='%' where user='root'; flush privileges;"
- "$mysql" -u "$mysql_user" -p"$mysql_password" -e "create database $mysql_db;"
- "$mysql_server" stop
- sleep 10
+}
+start_mysql() +{
- "$mysqld" --defaults-file=/etc/my.cnf --port="$mysql_port"
- sleep 20
+}
+main() +{
- local mysql="/usr/local/mysql/bin/mysql"
- local mysqld="/usr/local/mysql/bin/mysqld"
- local mysql_server="/usr/local/mysql/support-files/mysql.server"
- create_basedir
- configure_mysql
- create_database
- start_mysql
+}
+main
2.23.0