MySQL新建用户并赋予权限:解决命令行与Navicat展示数据库不一致问题

时间:2024-11-10 10:33:32

1.创建新用户 'xiaoxiao'密码'123456'

mysql> CREATE USER 'xiaoxiao'@'localhost' IDENTIFIED BY '123456';

2.问题:Navicat使用xiaoxiao链接,看不到新建的数据库testDB怎么办?

//用户添加使用testDB权限
grant all privileges on testDB.* to xiaoxiao@localhost identified by '123456';

3.为xiaoxiao用户添加远程访问权限

mysql> GRANT ALL PRIVILEGES ON testDB.* TO 'xiaoxiao'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

4.刷新权限表

flush privileges;

5.Navicat刷新,或者重新连接,ok!