MariaDB安装配置手册
Debian 12安装MariaDB
# 更新软件源
apt update
# 安装mariadb
apt install mariadb-server -y
# 执行安全引导
mysql_secure_installation
# 输入当前root密码,什么也不输入
Enter current password for root (enter for none):
# 是否切换到unix_socket认证,输入n
Switch to unix_socket authentication [Y/n] n
# 修改root密码,输入n
Change the root password? [Y/n] n
# 移除匿名用户,输入n
Remove anonymous users? [Y/n] y
# 阻止root远程登录,输入y
Disallow root login remotely? [Y/n] y
# 移除测试数据库和访问,输入y
Remove test database and access to it? [Y/n] y
# 立即刷新权限,输入y
Reload privilege tables now? [Y/n] y
mariadb的root用户采用unix_socket插件进行认证,而不是使用密码,最好再创建一个用户
# 修改username和password为您想要的用户名、密码
mariadb
mysql> GRANT ALL ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
mysql> exit
Docker安装MariaDB
docker pull mariadb:11.4.4
version: '3.1'
services:
mariadb:
image: mariadb:11.4.4
container_name: mariadb
environment:
MYSQL_ROOT_PASSWORD: my-secret-pw
MYSQL_DATABASE: mydatabase
ports:
- "3306:3306"
networks:
- mariadb_network
networks:
mariadb_network:
driver: bridge
常用命令
创建数据库
# 修改your_db_name、your_db_user和password为您想要的数据库名称、数据库用户名、密码
mariadb -u username -p
password #实际不显示
mysql> create database your_db_name character set utf8mb4 collate utf8mb4_bin;
mysql> create user 'your_db_user'@'localhost' identified by 'password';
mysql> grant all privileges on your_db_name.* to 'your_db_user'@'localhost';
mysql> exit
作者:ossdate 创建时间:2024-12-19 13:27
最后编辑:ossdate 更新时间:2024-12-30 19:53
最后编辑:ossdate 更新时间:2024-12-30 19:53