Kali使用MariaDB的认证问题
问题
安装完成或者忘记密码时会出现如下情况:
(这里先不考虑使用mysql_secure_installation初始化)
解决方案
1、
sudo vim /etc/mysql/mariadb.cnf
2、在下图所示的位置添加一行skip-grant-tables
3、重启服务
sudo systemctl restart mysql.service
4、无验证进入mysql,并进行如下操作
use mysql;
update user set authentication_string=password("在此处替换为你的密码") where user="root";
flush privileges;
5、注释掉第一步添加的skip-grant-tables
6、至此便可使用mysql -u root -p
输入密码进入了
若还是不行,特别是第一次使用时
原因是MariaDB的root默认连接方式是unix_socket
可以使用select user,plugin from user;
查看
1、将上面第五步注释的skip-grant-tables
取消注释使其再次生效
2、重启服务
sudo systemctl restart mysql.service
3、无验证进入mysql,并进行如下操作
use mysql;
update user set authentication_string=password("在此替换为你的密码"),plugin='mysql_native_password' where user='root';
flush privileges;
4、注释掉第一步添加的skip-grant-tables
5、至此便可使用mysql -u root -p
输入密码进入了
远程连接
如果你想使用远程连接,将/etc/mysql/mariadb.conf.d/50-server.cnf
中的bind-address
修改为允许的地址,改为0.0.0.0
或注释掉为不限制