问题:terminal中可以使用管理员账号登录mysql,但是在使用workbench时,报错如下。
mysql01尝试了许多方法,后来发现应该是由于用户的权限问题。
所以为了解决这一问题,可以新增一个MySQL用户,并让他拥有所有的权限。
1.创建用户
create user '用户名'@'localhost'identified by'密码';
mysql> create user 'bwj'@'localhost' identified by'666666';
Query OK, 0 rows affected (0.00 sec)
2.赋予全部权限
grant all on 权限 to 用户名@'localhost' identified by "密码";
mysql> grant all on *.* to bwj@'localhost' identified by "666666";
Query OK, 0 rows affected, 1 warning (0.01 sec)
3.查看用户权限
show grants for '用户名'@'localhost';
mysql> show grants for 'bwj'@'localhost';
+--------------------------------------------------+
| Grants for bwj@localhost |
+--------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'bwj'@'localhost' |
+--------------------------------------------------+
1 row in set (0.00 sec)
4.查看用户名
select user,host from mysql.user;
mysql> select user,host from mysql.user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| bwj | localhost |
| debian-sys-maint | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
| www | localhost |
+------------------+-----------+
6 rows in set (0.00 sec)
网友评论