1.mysql连接本地数据库
2.远程连接某个数据库
假设远程连接的数据库IP为10.124.56.78
- mysql -h10.123.89.90 -uroot -p1qazXSW@
3.创建某个数据库
- CREATE DATABASE IF NOT EXISTS garden default charset utf8 COLLATE utf8_general_ci;
4.创建某个用户并把数据权限
- GRANT ALL ON `garden`.* TO 'garden'@'%' IDENTIFIED BY "1qazXSW@";
- FLUSH PRIVILEGES;
这里前一个garden是数据库名称,*代表把garden下面所有表,后面的garden代表数据库用户,%号代表所有IP允许接入
只允许某个IP接入可以这样
- GRANT ALL ON `garden`.* TO 'garden'@'10.0.154.1' IDENTIFIED BY "1qazXSW@";
- FLUSH PRIVILEGES;
只允许localhost接入可以如下处理
- CREATE DATABASE IF NOT EXISTS garden default charset utf8 COLLATE utf8_general_ci;
- GRANT ALL ON `garden`.* TO 'garden'@'localhost' IDENTIFIED BY "1qazXSW@";
如果只赋予gardenCRUD的权力参考如下
- grant select,insert,update,delete on mydb.* to test2@localhost identified by "abc";
5.查看某个用户拥有哪些权限 (查看sanguotd的用户权限)
- show grants for sanguotd;
阅读(786) | 评论(0) | 转发(1) |