Fix unable to create rduser in MySQL v5.7+

The original insert into user's method of creating rduser is not compatible with MySQL v5.7+.

This moves to a standard create user statement.  Also moved to grant statements rather than
inserting directly into the db table to prevent possible changes to that causing issues in the
future.
This commit is contained in:
Wayne Merricks 2016-05-24 20:24:31 +01:00
parent 57aa913e6f
commit 5ff24a1374

View File

@ -240,17 +240,13 @@ and we will try to get this straightened out.");
if (check_remote_server(host)) { if (check_remote_server(host)) {
host=format_remote_host(host); host=format_remote_host(host);
} }
sql=QString().sprintf("insert into user set Host=\"%s\",\ sql=QString().sprintf("create user %s@'%s' identified by '%s'",
User=\"%s\",Password=PASSWORD(\"%s\")", (const char *)login, (const char *)host, (const char *)pwd);
(const char *)host, (const char *)login,(const char *)pwd);
q=new QSqlQuery(sql); q=new QSqlQuery(sql);
delete q; delete q;
sql=QString(). sql=QString().sprintf("grant SELECT, INSERT, UPDATE, DELETE, CREATE, DROP,\
sprintf("insert into db set Host=\"%s\",Db=\"%s\",\ INDEX, ALTER, LOCK TABLES on %s.* to %s@'%s'",
User=\"%s\",Select_priv=\"Y\",Insert_priv=\"Y\",Update_priv=\"Y\",\ (const char *)dbname, (const char *)login, (const char *)host);
Delete_priv=\"Y\",Create_priv=\"Y\",Drop_priv=\"Y\",\
Index_priv=\"Y\",Alter_priv=\"Y\",Lock_tables_priv=\"Y\"",
(const char *)host, (const char *)dbname,(const char *)login);
q=new QSqlQuery(sql); q=new QSqlQuery(sql);
delete q; delete q;
q=new QSqlQuery("flush privileges"); q=new QSqlQuery("flush privileges");