Created
February 15, 2021 14:23
-
-
Save wwwted/6d3cff6c671adf955c4a605bc39b8645 to your computer and use it in GitHub Desktop.
script to fire up a MySQL instance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MySQL_BIN="/home/ted/src/mysql-8.0.22-linux-glibc2.12-x86_64" | |
MySQL_HOME="/home/ted/sandboxes/cluster/node1" | |
## Do not touch below ;) | |
echo "1) Create MySQL instance" | |
# If $MySQL_HOME/data exists, stop MySQL + remove all | |
if [ -d $MySQL_HOME/data ] ; then | |
echo "1.5) Cleanup ...." | |
$MySQL_BIN/bin/mysqladmin -uroot -S$MySQL_HOME/mysql.sock shutdown | |
rm -fr $MySQL_HOME/data | |
fi | |
echo "2) Create folders for MySQL" | |
mkdir -p ${MySQL_HOME}/data | |
echo "3) Initialize and start MySQL" | |
${MySQL_BIN}/bin/mysqld --no-defaults --initialize-insecure --datadir=${MySQL_HOME}/data --basedir=${MySQL_BIN} | |
${MySQL_BIN}/bin/mysqld_safe --defaults-file=${MySQL_HOME}/my.cnf --ledir=${MySQL_BIN}/bin & | |
while [ ! -S ${MySQL_HOME}/mysql.sock ] | |
do | |
echo "Waiting for MySQL to start..." | |
sleep 2 | |
done | |
echo "4) Create user ted/ted" | |
${MySQL_BIN}/bin/mysql -uroot -S${MySQL_HOME}/mysql.sock -e"SET SQL_LOG_BIN=0; CREATE USER 'ted'@'%' IDENTIFIED BY 'ted'; GRANT ALL ON *.* TO 'ted'@'%' WITH GRANT OPTION"; | |
pgrep mysql | |
${MySQL_BIN}/bin/mysql -uted -pted -S${MySQL_HOME}/mysql.sock -e"status" | |
${MySQL_BIN}/bin/mysql -uted -pted -S${MySQL_HOME}/mysql.sock -e "select @@hostname, @@global.gtid_executed" | |
echo "5) Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment