mysql给每一个网站程序建立唯一的数据库连接帐号
为了安全我们通常给每一个网站程序建立唯一的数据库连接帐号(帐号名不能为root)。
mysql数据库其他用户的增加和删除:
1、以root用户登入,在mysql中有一张mysql.user表是存储MySQL中所有用户的信息表,所以可以直接增加删除这个表的记录就可增加和删除用户;
添加用户:添加一个用户名为 testuser,密码为 123\,授权为% (%表示所有 ip能连接,可以设置指定 ip)
MySQL [(none)]> grant all on *.* to testuser@”%” identified by “123″ ;
MySQL [(none)]> flush privileges; (刷新系统权限表)
2、添加数据库,添加test数据库的操作:
3、添加一个用户名为 testuser,密码为 123,授权为% ,对 test数据库所有权限,命令如下MySQL [(none)]>create database test;
MySQL [(none)]> grant all privileges on oneinstack.* to testuser@'%'identified by '123';
MySQL [(none)]> flush privileges;
4、这时使用MySQL账户testuser,密码123登入mysql数据库