Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mysql 8 Support #1805

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions func/db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,27 @@ add_mysql_database() {

query="CREATE DATABASE \`$database\` CHARACTER SET $charset"
mysql_query "$query" > /dev/null

# This can be modified for mysql 5.7 for better compatibility
if [ "$(echo $mysql_ver |cut -d '.' -f1)" -eq 8 ]; then
query="CREATE USER IF NOT EXISTS '$dbuser'@'localhost' IDENTIFIED BY '$dbpass';"
mysql_query "$query" > /dev/null
query="CREATE USER IF NOT EXISTS '$dbuser'@'%' IDENTIFIED BY '$dbpass';"
mysql_query "$query" > /dev/null
query="GRANT ALL ON \`$database\`.* TO \`$dbuser\`@\`%\`"
query="GRANT ALL ON \`$database\`.* TO \`$dbuser\`@localhost"
mysql_query "$query" > /dev/null
else
query="GRANT ALL ON \`$database\`.* TO \`$dbuser\`@\`%\`
IDENTIFIED BY '$dbpass'"
mysql_query "$query" > /dev/null

query="GRANT ALL ON \`$database\`.* TO \`$dbuser\`@localhost
IDENTIFIED BY '$dbpass'"
mysql_query "$query" > /dev/null

if [ "$(echo $mysql_ver |cut -d '.' -f2)" -ge 7 ]; then
fi
# for mysql 8 this will work only if mysql_native_password is enabled
# Not think yet how to add compatibility for new cached SHA-256 password system
if [ "$(echo $mysql_ver |cut -d '.' -f2)" -ge 7 ] || [ "$(echo $mysql_ver |cut -d '.' -f1)" -eq 8 ]; then
md5=$(mysql_query "SHOW CREATE USER \`$dbuser\`" 2>/dev/null)
md5=$(echo "$md5" |grep password |cut -f8 -d \')
else
Expand Down