Verlihub/verlihub

Invalid MySQL syntax during post-install database creation

rfilmyer opened this issue · 4 comments

When running vh --install, I ran into an issue when creating the database. After some bug hunting, I found it was because of this line:

$MYSQL --connect_timeout 5 -h "$MYSQL_HOST" -u "$MYSQL_ADMIN_USER" -e "CREATE DATABASE IF NOT EXISTS \`$MYSQL_DB_NAME\` CHARACTER SET \`utf8\` COLLATE \`utf8_unicode_ci\`; GRANT ALL ON \`$MYSQL_DB_NAME\`.* to '$MYSQL_USER'@'$CURRENT_ADDRESS' identified by '$MYSQL_PASSWORD'" &> /dev/null

The final command in that call, GRANT ALL ON db to user@ip identified by 'password', throws a syntax error on MySQL 8. IDENTIFIED BY is not a part of the GRANT command. If you remove it it works (eg GRANT ALL ON verlihub TO verlihub@verlihub executes fine, and IDENTIFIED BY isn't necessary because you created the user a few lines ago).

RoLex commented

alright. so workaround for this would be detection of mysql version and execution of different queries depending on version?

I notice that adding a user with vh -u similarly seems to fail, and the database looks to have not done the INSERT (since mysql errors get thrown to /dev/null I can't tell what the syntax error might be). What's the latest MySQL version that you guys have been able to get working with this without any problems?

It may be easier for me to get my server running on that, rather than try to get things working with a newer version, short-term.

RoLex commented

vh -u adds user to registered users list in your hub. its unrelated to mysql users.