更新时间:2022-12-18 15:28:45浏览次数:752+次
以下介绍在Ubuntu 22.04上安装和配置加固MariaDB的方法,同样的方法也适用于Ubuntu 20.04及18.04版本,使用本文的方法,实测安装出来的版本为MariaDB 10.6。
安装方法
首先添加存储库:
sudo apt install software-properties-common -y
curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
sudo bash mariadb_repo_setup
现在继续并安装MariaDB数据库服务器:
sudo apt update
sudo apt install mariadb-server mariadb-client
安装后,启动并启用MariaDB:
sudo systemctl start mariadb
sudo systemctl enable mariadb
配置加固方法
安装MariaDB后,请使用以下命令加固实例:
$ sudo mariadb-secure-installation
Enter current password for root (enter for none): Press Enter
Switch to unix_socket authentication [Y/n] Y
Change the root password? [Y/n] Y
New password: <NEW-PASSWORD>
Re-enter new password: <CONFIRM-NEW-PASSWORD>
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
Thanks for using MariaDB!
使用上面创建的密码登录MariaDB shell:
mysql -u root -p
然后可以为某个项目创建数据库或者在需要的时候再创建,比如现在为Wiki.js创建一个数据库:
CREATE DATABASE wikidb;
CREATE USER 'wikidb_user'@'localhost' IDENTIFIED BY 'Passw0rd';
GRANT ALL ON wikidb.* TO 'wikidb_user'@'localhost' WITH GRANT OPTION;
FLUSH privileges;
EXIT
至此,在Ubuntu 22.04上安装和配置加固MariaDB完成,用户可以将MariaDB用于实际部署项目。
相关资讯