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