0
点赞
收藏
分享

微信扫一扫

Mysql 创建用户与数据库

星河出山 2022-08-29 阅读 218

# 以root用户连接
mysql -u root -p

# 创建测试用户
create user test_user identified by '123456';

# 设置该测试用户,任意主机皆可连接
update user set host='%' where user='test_user';

# 创建数据库
create database test_db;

# 赋予刚创建的测试用户,所有新创建的数据库权限
grant all privileges on test_db.* to test_user;

# 刷新配置
flush privileges;

# 退出mysql登录
quit

 # 使用新创建的用户登录mysql
mysql -u test_user -p

# 使用新创建的数据库
use test_db;

# 显示当前用户(test_user)下当前数据库(test_db)下所有表的集合
# 此时并未创建表,故是表集合为空
show tables;


举报

相关推荐

0 条评论