在Debian系统上安装和配置MariaDB的步骤如下:
sudo apt update
sudo apt install mariadb-server mariadb-client libmariadb-dev
在安装过程中,系统可能会提示你确认是否继续安装,输入 Y 然后按回车键继续。
sudo mysql_secure_installation
该脚本将引导你完成以下操作:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'your_password';
FLUSH PRIVILEGES;
/etc/mysql/mariadb.conf.d/50-server.cnf 文件。bind-address 设置为 0.0.0.0 以允许远程连接。sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
# 将 bind-address = 127.0.0.1 修改为 bind-address = 0.0.0.0
sudo systemctl restart mariadb
sudo systemctl start mariadb
sudo systemctl stop mariadb
sudo systemctl restart mariadb
sudo systemctl status mariadb
如果MariaDB服务正在运行,会看到类似如下的输出:
● mariadb.service - MariaDB database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2024-01-14 13:16:27 CST; 22h ago
请注意,以上步骤中的某些操作(如允许root用户远程登录)可能会带来安全风险,请根据实际需求和环境谨慎操作。