PHP创建Mysql数据库,然后给用户使用这个库的使用权限操作,如何实现?
发布网友
发布时间:2022-04-07 23:03
我来回答
共2个回答
热心网友
时间:2022-04-08 00:33
mysql 创建一个用户 hail,密码 hail,指定一个数据库 haildb 给 hail
mysql -u root -p
password
use mysql;
insert into user(host,user,password) values('localhost','hail',password('hail'));
flush privileges;
create database haildb;
grant all privileges on haildb.* to hail@localhost identified by 'hail';
flush privileges;
如果想指定部分权限给用户
grant select,update on haildb.* to hail@localhost identified by 'hail';
flush privileges;
删除用户
delete from user where user='hail' and host='localhost';
flush privileges;
删除用户数据库
drop database haildb;
修改指定用户密码
update user set password=password('new_password') where user='hail' and host='localhost';
flush privileges;
热心网友
时间:2022-04-08 01:51
这个是用mysql端设置的,如果你用来php开发环境有phpmyadmin的话,就在
phpmyadmin设置