- 创建用户:
mysql> insert into mysql.user(Host,User,Password) values("localhost","test",password("1234"));
这样就创建了一个名为:test 密码为:1234 的用户。
注意:此处的"localhost",是指该用户只能在本地登录,不能在另外一台机器上远程登录。如果想远程登录的话,将"localhost"改为"%",表示在任何一台电脑上都可以登录。 也可以指定某台机器可以远程登录。
为用户授权
授权格式:grant 权限 on 数据库.* to 用户名@登录主机 identified by "密码";
grant all privileges on *.* to root@"%" identified by "root";
flush privileges;