树莓派安装Mariadb数据库

1. 更新系统

在安装Mariadb数据库之前,先更新系统

sudo apt update -y
sudo apt upgrade -y

2. 安装Mariadb

安装命令如下:

sudo apt install mariadb-server -y

查看服务状态:

sudo systemctl status mariadb

结果如下即为安装成功
在这里插入图片描述

3. 配置Mariadb

运行以下命令进行配置:

sudo mysql_secure_installation
  • Enter current password for root (enter for none):直接按回车
  • Switch to unix_socket authentication [Y/n]:y 回车
  • Change the root password? [Y/n]:y 回车
  • New password: 输入你要设置的密码,输入完按回车
  • Re-enter new password: 确认密码,输入完按回车
  • Remove anonymous users? [Y/n]: y 回车
  • Disallow root login remotely? [Y/n]: n 回车
  • Remove test database and access to it? [Y/n]:n回车
  • Reload privilege tables now? [Y/n]:y 回车
    在这里插入图片描述

4. 登录Mariadb

运行以下命令登录Mariadb:

mysql -u root -p

输入刚刚设置的密码即可登录,登录成功如下图
在这里插入图片描述

5. 远程连接

  • 修改配置
    sudo vim /etc/mysql/mariadb.conf.d/50-server.cnf
    
  • 重启服务
    sudo systemctl restart mariadb
    
  • 开放远程连接(这里以root用户为例,第一个root代表用户,第二个root代表密码)
    登录mariadb后,执行如下命令:
    GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
    
  • 刷新权限
    FLUSH PRIVILEGES;
    
  • 使用工具验证
    在这里插入图片描述
  • 6
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值