Linux安装mysql(mariadb)数据库

要在Raspberry Pi上安装MariaDB数据库,您可以按照以下步骤进行操作:

注意:在进行此过程之前,请确保您的Raspberry Pi已经运行并已连接到互联网。

  1. 打开终端窗口,可以通过SSH连接到您的Raspberry Pi,或者直接在Raspberry Pi的终端中进行操作。
  2. 更新包列表,以确保您的系统是最新的:
    sqlCopy code
    sudo apt update
  3. 安装MariaDB服务器软件包:
    Copy code
    sudo apt install mariadb-server
  4. 安装完成后,启动MariaDB服务器并确保它在系统启动时自动启动:
    bashCopy code
    sudo systemctl start mariadb sudo systemctl enable mariadb
  5. 为了增加安全性,运行MariaDB安全性脚本来设置root密码、删除匿名用户、禁用root远程登录等操作:
    Copy code
    sudo mysql_secure_installation
    在此过程中,您将被提示输入刚刚设置的root密码,并回答一些安全性问题。按照屏幕上的指示操作。
  6. MariaDB已经安装并配置完成了。您可以使用以下命令来登录到MariaDB服务器:
    cssCopy code
    sudo mysql -u root -p
    输入您设置的MariaDB root密码,然后就可以登录到MariaDB服务器了。
  7. 现在,您可以创建和管理数据库、用户等等,根据您的项目需求进行操作。

请注意,MariaDB与MySQL兼容,因此您可以使用标准的MySQL命令来管理MariaDB。希望这些步骤能帮助您在Raspberry Pi上安装和配置MariaDB数据库。如果您遇到任何问题,请提供详细的错误消息,以便我能够更好地帮助您解决问题。

1、MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'test'@'%' IDENTIFIED BY 'your_password';

Query OK, 0 rows affected (0.004 sec)

2、MariaDB [(none)]> SELECT user, host, authentication_string FROM mysql.user;

+-------------+-----------+-------------------------------------------+

| User | Host | authentication_string |

+-------------+-----------+-------------------------------------------+

| mariadb.sys | localhost | |

| root | localhost | invalid |

| mysql | localhost | invalid |

| test | % | *9E72259BA9214F692A85B240647C4D95B0F2E08B |

3、sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf

4、bind-address = 0.0.0.0

保存更改:在 nano 编辑器中,按 Ctrl + O 键,然后按 Enter 键来保存更改。接着,按 Ctrl + X 键来退出编辑器。

5、账号是test 密码是%的密码

C:\Users\Michael Zhao>mysql -u test -h 192.168.0.109 -p

Enter password: *************

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 32

Server version: 5.5.5-10.5.19-MariaDB-0+deb11u2 Raspbian 11

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input s

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值