添加新用户
允许本地 IP 访问 localhost, 127.0.0.1 copy
create user
'用户名'
@
'localhost'
identified
by
'密码'
;
create user
'用户名'
@
'%'
identified
by
'密码'
;
刷新授权
flush privileges
;
为用户创建数据库
create database test DEFAULT CHARSET utf8 COLLATE utf8_general_ci
;
为新用户分配权限
授予用户通过外网IP对于该数据库的全部权限
grant all privileges on \`
数据库名
\`
.*
to
'test'
@
'%'
identified
by
'密码'
;
如果是
mysql8
以上这句话要改为
grant all privileges on
`数据库名`
.*
to
'用户名'
@
'localhost'
WITH GRANT OPTION
;
授予用户在本地服务器对该数据库的全部权限
grant all privileges on
`数据库名`
.*
to
'用户名'
@
'localhost'
identified
by
'密码'
;
如果是
mysql8
以上这句话要改为
grant all privileges on
`数据库名`
.*
to
'用户名'
@
'localhost'
WITH GRANT OPTION
;
刷新权限
flush privileges
;
退出 root 重新登录
用新帐号 test 重新登录,由于使用的是 % 任意IP连接
全部评论