Note: This is also a MySQL 8 workaround for the new caching_sha2_password authentication plugin.
Example below uses the legacy mysql_native_password
instead for compatibility reasons.
CREATE USER `my_root_user`@`%` IDENTIFIED WITH mysql_native_password BY 'my_root_pwd';
GRANT Alter, Alter Routine, Create, Create Routine, Create Temporary Tables,
Create User, Create View, Delete, Drop, Event, Execute, File, Grant Option,
Index, Insert, Lock Tables, Process, References, Reload, Replication Client,
Replication Slave, Select, Show Databases, Show View, Shutdown, Trigger, Update
ON *.* TO `my_root_user`@`%`;
CREATE USER `my_user`@`%` IDENTIFIED WITH mysql_native_password BY 'my_password';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE
ON `my_database`.* TO `my_user`@`%` WITH GRANT OPTION;
ALTER USER 'my_root_user'@'localhost' IDENTIFIED BY 'MyNewPassword';