版本5.7
CREATE DATABASE `databasename`;
CREATE USER 'username'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON `databasename`.* TO 'username'@'%' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
版本8.0
CREATE DATABASE `databasename`;
CREATE USER 'username'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON `databasename`.* TO 'username'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;