mysql给用户 创建数据库的权限吗

mysql给用户 创建数据库的权限吗,第1张

登录MySQL

[plain] view plain copy print

mysql -u root -p

添加新用户

允许本地 IP 访问 localhost, 127001

[plain] view plain copy print

create user 'test'@'localhost' identified by '123456';

允许外网 IP 访问

[plain] view plain copy print

create user 'test'@'%' identified by '123456';

刷新授权

[sql] view plain copy print

flush privileges;

为用户创建数据库

[sql] view plain copy print

create database test DEFAULT CHARSET utf8 COLLATE utf8_general_ci;

为新用户分配权限

授予用户通过外网IP对于该数据库的全部权限

[sql] view plain copy print

grant all privileges on `testdb` to 'test'@'%' identified by '123456';

授予用户在本地服务器对该数据库的全部权限

[sql] view plain copy print

grant all privileges on `testdb` to 'test'@'localhost' identified by '123456';

刷新权限

[sql] view plain copy print

flush privileges;

退出 root 重新登录

[sql] view plain copy print

exit

用新帐号 test 重新登录,由于使用的是 % 任意IP连接,所以需要指定外部访问IP

首先进入命令行下:

以root用户登录,命令:mysql

-uroot

-p

回车

输入密码;

mysql>use

mysql;

mysql>UPDATE

user

SET

password=PASSWORD('输入新密码')

WHERE

user='root';

mysql>FLUSH

PRIVILEGES;

已经完成。

以上就是关于mysql给用户 创建数据库的权限吗全部的内容,包括:mysql给用户 创建数据库的权限吗、怎么设置mysql数据库用户名和密码、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/9366173.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-27
下一篇 2023-04-27

发表评论

登录后才能评论

评论列表(0条)

保存