qinghemo

Kali-MariaDB安装使用

据说mysql现在对kali收费,所以得用其他数据库代替,这里倒腾了下mariadb


安装

  1. 安装mariadb-client
sudo apt-get install mariadb-client
  1. 安装mariadb-server
sudo apt-get install mariadb-server
  1. 设置为开机启动服务
systemctl enable mysql

# 停止开机启动可以用如下命令
# systemctl disable mysql

使用

初始化

第一次使用时,需要初始化,此时设置登录数据库的密码

mysql_secure_installation 

忘记密码

  1. 知道数据库root密码需要修改,直接在shell修改
mysqladmin -uroot -p[oldpassword] password newpassword
  1. 登录数据库修改
use mysql;
-- 查看数据库用户信息
select host,user,plugin,authentication_string from mysql.user;
-- 修改密码
UPDATE user SET password=password(\'newpassword\') WHERE user=\'root\';
-- 新版MySQL采用此SQL
UPDATE user SET authentication_string=PASSWORD(\'newpassword\') where USER=\'root\';
-- 修改密码
ALTER USER \'root\'@\'localhost\' IDENTIFIED WITH mysql_native_password BY \'123456\';
flush privilieges;
exit;
  1. 使用set指令设置root密码
    登录数据库
SET password for \'root\'@\'localhost\'=password(\'newpassword\'); 
exit; 
  1. 忘记数据库root密码,则要跳过授权的方式启动mariadb以修改密码
# 停止服务
systemctl stop mariadb
# 设置跳过授权启动mariadb,然后登录数据库用2,3方法修改数据库密码
mysqld_safe --skip-grant-tables &
# 修改密码后,跳权启动设置失效,设置正常启动mariadb
systemctl start mariadb
  1. 修改登录mariadb的方式,从unix socket密码登录
    Mariadb在5.2.0以后的版本默认不再使用密码认证了,改用Authentication Plugin - Unix Socket插件认证。而Unix Socke插件认证直接忽略密码. 通过以下方式可以切换回密码登录
use mysql;
update mysql.user set plugin=\'mysql_native_password\' where User=\'root\';
flush privileges;

卸载

sudo apt-get remove mariadb-client
sudo apt-get autoremove mariadb-client

sudo apt-get remove mariadb-server
sudo apt-get autoremove mariadb-server

分类:

技术点:

相关文章:

  • 2021-12-13
  • 2021-12-13
  • 2022-01-10
  • 2021-11-21
  • 2021-08-21
  • 2022-03-04
  • 2021-12-13
  • 2022-02-18
猜你喜欢
  • 2021-11-28
  • 2021-12-13
  • 2021-09-29
  • 2021-12-13
  • 2021-12-13
  • 2021-04-26
  • 2021-11-19
相关资源
相似解决方案