MySQL创建用户及名下数据库
创建用户及同名数据库
CREATE USER 'HttpApi'@'localhost' IDENTIFIED WITH mysql_native_password;
GRANT USAGE ON *.* TO 'HttpApi'@'localhost' REQUIRE NONE WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;
SET PASSWORD FOR 'HttpApi'@'localhost' = PASSWORD('******');
CREATE DATABASE IF NOT EXISTS `HttpApi`;
GRANT ALL PRIVILEGES ON `HttpApi`.* TO 'HttpApi'@'localhost';
GRANT ALL PRIVILEGES ON `HttpApi\_%`.* TO 'HttpApi'@'localhost';
创建用户及分配多个数据库
CREATE USER 'apollo'@'%' IDENTIFIED WITH mysql_native_password;
GRANT USAGE ON *.* TO 'apollo'@'%' REQUIRE NONE WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;
SET PASSWORD FOR 'apollo'@'%' = PASSWORD('******');
CREATE DATABASE IF NOT EXISTS `ApolloPortalDB`;
GRANT ALL PRIVILEGES ON `ApolloPortalDB`.* TO 'apollo'@'%';
GRANT ALL PRIVILEGES ON `ApolloPortalDB\_%`.* TO 'apollo'@'%';
CREATE DATABASE IF NOT EXISTS `ApolloConfigDB`;
GRANT ALL PRIVILEGES ON `ApolloConfigDB`.* TO 'apollo'@'%';
GRANT ALL PRIVILEGES ON `ApolloConfigDB\_%`.* TO 'apollo'@'%';
版权声明:
作者:Joe.Ye
链接:https://www.appblog.cn/index.php/2023/02/26/mysql-creates-users-and-databases/
来源:APP全栈技术分享
文章版权归作者所有,未经允许请勿转载。
THE END
0
二维码
打赏
海报
MySQL创建用户及名下数据库
创建用户及同名数据库
CREATE USER 'HttpApi'@'localhost' IDENTIFIED WITH mysql_native_password;
GRANT USAGE ON *.* TO 'HttpAp……
文章目录
关闭
共有 0 条评论