1.创建一个mysql用户并设置密码
create user 'MySql用户名'@'localhost' identified by '密码';
2.限制账户资源
grant usage on *.* to 'MySql用户名'@'localhost' identified by '密码' WITH
MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0
MAX_USER_CONNECTIONS 0;
3.创建数据库
create database if not exists 数据库名;
4.赋予权限
grant all privileges on 数据库名.* to 'MySql用户名'@'localhost';
5.更新数据库数据(在做任何更动后,建议要使用这指令)
flush privileges;
例子:
create user 'buyuba'@'localhost' identified by '99dianwan20130718';
grant usage on *.* to 'buyuba'@'localhost' identified by
'99dianwan20130718' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR
0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;
create database if not exists www_77jieji_com;
grant all privileges on www_77jieji_com.* to 'buyuba'@'localhost';