mysql允许远程机器连接
mysql> use mysql; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> select host, user from user; +---------------+---------------+ | host | user | +---------------+---------------+ | % | root | | 192.168.0.% | root | | 192.168.0.1.% | root | | localhost | mysql.session | | localhost | mysql.sys | | localhost | root | +---------------+---------------+ 6 rows in set (0.00 sec) mysql> update user set host='%' where user='root'; ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY' #不用管,没有影响,直接下一步 mysql> flush privileges; Query OK, 0 rows affected (0.02 sec) 重启数数据,否则不生效 systemctl restart mysqld mysql> grant all privileges on *.* TO 'root'@'%' identified by 'jenkins@123' with grant option; Query OK, 0 rows affected, 1 warning (0.02 sec) mysql>grant all on *.* to root@'localhost' identified by 'jenkins@123' with grant option; mysql> alter user 'root'@'localhost' identified by 'jenkins@123'; mysql> flush privileges; Mysql>exit