当前位置: 代码迷 >> 综合 >> MySQL 新建用户,为用户授权,指定用户访问数据库
  详细解决方案

MySQL 新建用户,为用户授权,指定用户访问数据库

热度:72   发布时间:2024-03-09 17:04:01.0

1.登录MySQL

mysql -u root -p 

2.添加新用户(允许所有ip访问)

create user 'test'@'*' identified by '123456';(test:用户名,*:所有ip地址,123456:密码)

3.创建数据库

create database testdb;

4.为新用户分配权限

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

5.刷新权限

flush privileges;

  相关解决方案