本文主要是介绍mysql建库授权删库,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
用户配置库
CREATE DATABASE IF NOT EXISTS ***_config DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
业务库
CREATE DATABASE IF NOT EXISTS ***_cms DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
建用户与权限
##默认无密码,修改密码
mysql -uroot -h 10.10.11.1 -P 3306 -p
use mysql;
SET PASSWORD FOR 'root'@'%' = '***passwd';
ALTER USER 'root'@'10.10.11.%' IDENTIFIED BY '***passwd';备份相关:
#授予管理员权限(不建议权限太大用户) 设置访问白名单,例如localhost 10.10.104.网段
GRANT ALL PRIVILEGES ON *.* TO ***_user@"localhost" IDENTIFIED BY "***passwd";
GRANT ALL PRIVILEGES ON *.* TO ***_user@"10.10.104.%" IDENTIFIED BY "***passwd";
GRANT ALL PRIVILEGES ON *.* TO ***_user@"192.168.30.%" IDENTIFIED BY "***passwd";#GRANT ALL PRIVILEGES ON *.* TO ***_user@"%" IDENTIFIED BY "***passwd";
备份还原
mysqldump -uroot -p --all-databases > $(date +'%Y%m%d%H%M')bak.sql
删库–危险
#!@# DROP DATABASE IF EXISTS ***_config;
show databases;
这篇关于mysql建库授权删库的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!