1、登录宝塔面板进行安装
2、设置MySQL连接密码
3、安装好了设置navicat连接
登录MySQL
[root@hecs-394544 ~]# mysql -uroot -p
Enter password:
切换到MySQL数据
mysql> use mysql
Database changed
mysql>
查询用户信息
mysql> select host,user from user;
+-----------+------------------+
| host | user |
+-----------+------------------+
| % | root |
| 127.0.0.1 | test1 |
| localhost | mysql.infoschema |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | test1 |
+-----------+------------------+
6 rows in set (0.00 sec)
mysql>
第一行host是我自己添加的,最下面一行是一开始就有的root账户,可以直接把user表的root账户对应的host改为’%'就可以在Navicat上远程登录了,就是SQL的update语句,不用搞得那么复杂
update user set host = '%' where host = 'localhost' and user = 'root';
mysql> update user set host = '%' where host = 'localhost' and user = 'root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> select host,user from user;
+-----------+------------------+
| host | user |
+-----------+------------------+
| % | root |
| 127.0.0.1 | test1 |
| localhost | mysql.infoschema |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | test1 |
+-----------+------------------+
6 rows in set (0.00 sec)
mysql>
刷新权限
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>
设置navicat连接
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456'; ### 123456 mysql的登录密码
Query OK, 0 rows affected (0.00 sec)
mysql>
刷新权限
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>