2022年版的MariaDB安装至Raspberry Pi.
首先
树莓派 + MariaDB 的组合是我经常使用的,但是在最新环境下安装到树莓派操作系统后,无法从外部终端访问。原因不太清楚,可能是由于操作系统变为 bullseye 版本的影响吧?
我进行了各种尝试和错误,现在将其作为备忘录分享出来。
由于我是业余玩家,可能会存在错误的地方。目前只确认能够正常运行。
另外,旧的方法在这里。
2. 安装步骤
首先更新系统,然后安装MariaDB。
$ sudo apt update
$ sudo apt install -y mariadb-server
以前,当安装完毕后,我们会登录到MariaDB并更改用户权限等,但由于认证套接字被更改,因此无法进行更改。作为替代,我们使用了一个名为mysql_secure_installation的工具进行更改。
$sudo mysql_secure_installation
由于有各种各样的问题被问到,所以请按以下方式输入。
Enter current password for root (enter for none): <--何も押さずにEnter
Switch to unix_socket authentication [Y/n]: <--n
Change the root password? [Y/n]: <--y
New password: <--MariaDBのrootユーザー用パスワードを新規作成
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]: <--y
Reload privilege tables now? [Y/n]: <--y
接下来,我们将在配置文件中将限制本地访问的行注释掉。
$ sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
我們將以注釋形式將binde-address行從打開的文件中註釋掉。
#binde-address =127.0.0.1
接下来,我们将登录MariaDB并允许外部终端的访问。
$ mysql -u root -p
Enter password:
如果被问到密码,请输入先前创建的密码并输入权限更改的指令。
MariaDB[(none)]> grant all privileges on *.* to root@"%" identified by 'your password' with grant option;
MariaDB[(none)]> exit
完成设置后,重新启动MariaDB即可完成。
$ suod systemctl restart mysql
已经完成了。