Skip to content

Commit

Permalink
drush site-install fails with MySQL 8 #4259 (#4261)
Browse files Browse the repository at this point in the history
* drush site-install fails with MySQL 8 #4259

* Drop user if exists
  • Loading branch information
AdamPS authored and greg-1-anderson committed Jan 2, 2020
1 parent dcb05c0 commit b559117
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/Drush/Sql/Sqlmysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ public function createdb_sql($dbname, $quoted = FALSE) {
// - If the database is on a remote server, create a wilcard user with %.
// We can't easily know what IP adderss or hostname would represent our server.
$domain = ($this->db_spec['host'] == 'localhost') ? 'localhost' : '%';
$sql[] = sprintf('GRANT ALL PRIVILEGES ON %s.* TO \'%s\'@\'%s\'', $dbname, $this->db_spec['username'], $domain);
$sql[] = sprintf("IDENTIFIED BY '%s';", $this->db_spec['password']);
$user = sprintf("'%s'@'%s'", $this->db_spec['username'], $domain);
$sql[] = sprintf("DROP USER IF EXISTS %s;", $user);
$sql[] = sprintf("CREATE USER %s IDENTIFIED WITH mysql_native_password BY '%s';", $user, $this->db_spec['password']);
$sql[] = sprintf('GRANT ALL PRIVILEGES ON %s.* TO %s;', $dbname, $user);
$sql[] = 'FLUSH PRIVILEGES;';
}
return implode(' ', $sql);
Expand Down

0 comments on commit b559117

Please sign in to comment.