MySQL创建用户并设置某个数据库权限
CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'strong_password';
GRANT ALL PRIVILEGES ON database1.* TO 'new_user'@'localhost';
GRANT ALL PRIVILEGES ON database2.* TO 'new_user'@'localhost';
GRANT ALL PRIVILEGES ON database3.* TO 'new_user'@'localhost';
FLUSH PRIVILEGES;
需要远程连接,把localhost换成%
例如
CREATE USER 'shiyisc'@'%' IDENTIFIED BY 'Dymwan520';
GRANT ALL PRIVILEGES ON account.* TO 'shiyisc'@'%';
GRANT ALL PRIVILEGES ON order.* TO 'shiyisc'@'%';
GRANT ALL PRIVILEGES ON business.* TO 'shiyisc'@'%';
GRANT ALL PRIVILEGES ON storage.* TO 'shiyisc'@'%';
FLUSH PRIVILEGES;