Linux中MySQL下添加用户以及给予权限的实现

peakswill2周前Linux31
     1、在linux中首先登入mysql:mysql -u root -p(提示输入密码,输入即可)
     2、选择mysql数据库:use mysql。
             在mysql表中插入系统的用户名和用户密码:
               insert into user(Host,User,Password) values("localhost","你的用户名",password("你要设置的密码"));
     3、刷新mysql系统相关的表:flush privileges;
     4、给新增的用户添加管理数据库的所有权限:
               grant all on 数据库.数据库表(用*表示对应数据库下面所有的表格) to 用户名称;

注:(有问题可尝试重启mysql)
     grant select,insert,update,delete,create,drop on company.employee to yoyo@10.11.12.13 identified by‘123′;
     是指用户yoyo能够从ip为10.11.12.13的主机上使用密码123来登录并对数据库company对应的表employee实行 select,insert,update,delete,create,drop操作。
     ip地址可以自由限制,或者不限制就改为*。
     权限都有select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file14个权限,当要所有的权限是直接改为grant all privileges on。