User creation has changed in MySQL 8.0

Created on 4 June 2020, over 4 years ago
Updated 15 February 2024, 10 months ago

Problem

When verifying a (remote) server running MySQL 8.0 (default on Ubuntu 20.04), we get:

Unable to grant privileges to database users.

This appears to be due to no longer being able to implicitly create a user using GRANT. The supported syntax now requires two statements:

CREATE USER 'username' IDENTIFIED BY 'password';
GRANT alter,create,delete,[...] ON database.* TO 'username';

This is handled in Provision_Service_db_mysql::grant(), where we call:

$this->query("GRANT ALL PRIVILEGES ON `%s`.* TO `%s`@`%s` IDENTIFIED BY '%s'", $name, $username, $host, $password)

The 2-statement syntax (CREATE USER,then GRANT) appears to be backwards compatible to MySQL 5, so we could:

  1. update the syntax in grant();
  2. add a new create_user() method (called from grant()?);
  3. determine the version of MySQL and switch syntax based on that; or
  4. subclass Provision_Service_db_mysql and override grant() with the new syntax.

Remaining tasks

  1. The second one needs testing still.
  2. For the MariaDB problem (#16) , I think we can add that to the release notes.
🐛 Bug report
Status

Fixed

Version

3.0

Component

DB Service

Created by

🇨🇦Canada ergonlogic Montréal, Québec 🇨🇦

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024