1:以root身份登陆mysql终端
mysql -uroot -pmysql
2:创建wx用户,注意密码要加单引号
mysql> create user wx identified by 'wx';
3:创建wx数据库
mysql>create database wx;
4:为用户wx授权使其拥有wx数据库的所有权限
mysql> grant all on wx.* to wx@localhost identified by 'wx';
如果要为用户wx授予所有权限则:
mysql>grant all on *.* to wx@localhost identified by 'wx';
5:刷新系统权限表
mysql> flush privileges;
6:退出root用户,以wx 用户登陆
mysql -uwx -pwx
查看数据库信息
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| wx |
+--------------------+
7:授权允许远程链接
允许所有以wx用户登陆密码为wx的所有主机(%)进行链接访问,并授予所有权限:
mysql> grant all privileges on *.* to 'wx'@'%' identified by 'wx' with grant option;
Query OK, rows affected (0.00 sec)
远程链接测试
y@y:~$ mysql -uwx -pwx -h公网IP -Dwx