Skip to content

Commit 08d84bc

Browse files
committed
Make database code work with mysql8
The GRANT command in mysql8 can no longer create a user implicitly. Split that part into a dedicated CREATE USER command. Also drop disabling the query_cache, it is off by default for some time and the option got removed in mysql8. Change-Id: I31bcc285ff8e373abbacb303c1269857c9cfa9ed
1 parent 64ae083 commit 08d84bc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/databases/mysql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,10 @@ function configure_database_mysql {
109109
sudo mysql $cmd_args -e "UPDATE mysql.user SET plugin='' WHERE user='$DATABASE_USER' AND host='localhost';"
110110
sudo mysql $cmd_args -e "FLUSH PRIVILEGES;"
111111
fi
112+
# Create DB user if it does not already exist
113+
sudo mysql $cmd_args -e "CREATE USER IF NOT EXISTS '$DATABASE_USER'@'%' identified by '$DATABASE_PASSWORD';"
112114
# Update the DB to give user '$DATABASE_USER'@'%' full control of the all databases:
113-
sudo mysql $cmd_args -e "GRANT ALL PRIVILEGES ON *.* TO '$DATABASE_USER'@'%' identified by '$DATABASE_PASSWORD';"
115+
sudo mysql $cmd_args -e "GRANT ALL PRIVILEGES ON *.* TO '$DATABASE_USER'@'%';"
114116

115117
# Now update ``my.cnf`` for some local needs and restart the mysql service
116118

@@ -120,8 +122,6 @@ function configure_database_mysql {
120122
iniset -sudo $my_conf mysqld sql_mode TRADITIONAL
121123
iniset -sudo $my_conf mysqld default-storage-engine InnoDB
122124
iniset -sudo $my_conf mysqld max_connections 1024
123-
iniset -sudo $my_conf mysqld query_cache_type OFF
124-
iniset -sudo $my_conf mysqld query_cache_size 0
125125

126126
if [[ "$DATABASE_QUERY_LOGGING" == "True" ]]; then
127127
echo_summary "Enabling MySQL query logging"

0 commit comments

Comments
 (0)