mysql数据库授权操作

2025-04-22 17:45:17

1、查看数据库权限:1、查看数据库是否有授权的权限:select *from mysql.user where User='root' and Host='%'\G;2、在列出的内容中查看Grant_priv:是否为Y3、当Grant_priv:不为Y时:update mysql.user set Grant_priv='Y' where User='root' and Host='%';4、刷新权限设置:flush privileges;5、退出当前账户:quit

2、数倌栗受绽据库授权:1、用root登陆数据库:mysql -h 数据库ip -uroot -p数据库密码2、创建用户:create user '新建的用户名'@'192.168.42.67' identified by '密码';3、授权:GRANT ALL PRIVILEGES ON *.* TO '新建的用户名'@'%/主机内网' IDENTIFIED BY '密码' WITH GRANT OPTION;4、授权成功后刷新权限设置:flush privileges;5、之后就可以用新授权的用户登陆了:mysql -h 数据库ip -u 新建的用户名 -p密码

3、授权过程可能遇到的小问题:发现无密码条件下,没有授权的写权限:The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement解决方法:mysql> set global read_only=0;//(关掉新主库的只读属性)mysql>flush privileges;mysql>set global read_only=1;//(读写属性)mysql>flush privileges;重启数据库

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢