xiaobingch

一、创建用户并授权

1. 登录mysql 

mysql -u root -q
输入密码
2. 创建数据库(已有数据库就不需要建立)

create database newDB;//以创建newDB为例
3. 创建用户

创建userone,只能本地访问

 create user userone@\'localhost\' identified by \'password\';
创建usertwo,可以远程访问

 create user usertwo@\'%\' identified by \'password\';

\'%\' - 所有情况都能访问
‘localhost’ - 本机才能访问
’111.222.33.44‘ - 指定 ip 才能访问

4. 修改用户密码

以userone为例:

 set password for \'userone\'@\'%\'=password(\'1234\')
5. 为用户授权

授予userone管理newDB的全部权限 

grant all privileges on dbdata.*@\'%\' to userone identified by \'1234\';
授予userone全部数据库权限,并修改密码

 grant all on *.* to \'usertwo\'@\'%\' identified by \'123456\';

分类:

技术点:

相关文章:

  • 2021-10-04
  • 2021-12-15
  • 2021-10-06
  • 2021-10-04
  • 2021-09-07
  • 2018-06-01
  • 2021-11-03
  • 2021-10-04
猜你喜欢
  • 2021-11-30
  • 2021-12-16
  • 2021-10-04
  • 2021-10-10
  • 2021-10-04
  • 2021-12-26
  • 2021-10-04
相关资源
相似解决方案