1、查看mysql服务端口是否为外部端口,如果监听的是本地端口修改mariadb配置文件
root@kali:~# whereis mysql mysql: /usr/bin/mysql /etc/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz root@kali:~# cd /etc/mysql root@kali:/etc/mysql# ls conf.d debian.cnf debian-start mariadb.cnf mariadb.conf.d my.cnf my.cnf.fallback root@kali:/etc/mysql# cd mariadb.conf.d/ root@kali:/etc/mysql/mariadb.conf.d# ls 50-client.cnf 50-mysql-clients.cnf 50-mysqld_safe.cnf 50-server.cnf root@kali:/etc/mysql/mariadb.conf.d# cat 50-server.cnf
将bind-address改为 0.0.0.0 全局监听
root@kali:/etc/mysql/mariadb.conf.d# netstat -ant
2、mysql外部连接默认为关闭状态,开启
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
3、mysql root无密码时,修改密码
UPDATE user SET password=PASSWORD('123456') WHERE User='root';