MariaDB是一个开源的关系数据库管理系统。它最后被设计为MySQL的向后兼容二进制二进制替换。MariaDB由MySQL的原始开发人员和凋谢源代码社区开发和保护。本指南阐明了如何在Ubuntu 20.04(WSL)上装置和爱护MariaDB。
1、根底条件本文装置环境为Ubuntu20.04 on WSL(Windows Subsystem for Linux),咱们假如您具备root用户或具备sudo权限的治理拜访权限。
2、装置MariaDBsudo apt updatesudo apt -y install mariadb-server装置实现后,MariaDB服务不会主动启动,请应用上面命令启动MariaDB服务:
sudo service mysql start3、配置MariaDBMariaDB服务有一个脚本叫做mysql_secure_installation,它容许你能够很容易进步数据库服务器平安。执行不带参数的脚本:
sudo mysql_secure_installation该脚本将提醒您输出root明码,因为您尚未设置root明码,只需在此处按“ Enter”。
Enter current password for root (enter for none):在下一个提示符下,将要求您设置MySQL root用户的明码,输出n:
Set root password? [Y/n] n在Ubuntu上,auth_socket默认状况下插件会对MariaDB根用户进行身份验证。该插件通过查看调用客户端程序的本地零碎用户是否与指定的MariaDB用户名匹配来工作。
接下来,将要求您删除匿名用户,限度root用户对本地计算机的拜访,删除测试数据库并从新加载特权表。能够依照本人的爱好来批改:
# sudo mysql_secure_installationNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB to secure it, we'll need the currentpassword for the root user. If you've just installed MariaDB, andyou haven't set the root password yet, the password will be blank,so you should just press enter here.Enter current password for root (enter for none):OK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MariaDBroot user without the proper authorisation.# 批改root用户明码Set root password? [Y/n] n ... skipping.By default, a MariaDB installation has an anonymous user, allowing anyoneto log into MariaDB without having to have a user account created forthem. This is intended only for testing, and to make the installationgo a bit smoother. You should remove them before moving into aproduction environment.# 删除匿名用户Remove anonymous users? [Y/n] y ... Success!Normally, root should only be allowed to connect from 'localhost'. Thisensures that someone cannot guess at the root password from the network.# 禁止root近程登录Disallow root login remotely? [Y/n] n ... skipping.By default, MariaDB comes with a database named 'test' that anyone canaccess. This is also intended only for testing, and should be removedbefore moving into a production environment.# 删除测试数据库和拜访权限Remove test database and access to it? [Y/n] n ... skipping.Reloading the privilege tables will ensure that all changes made so farwill take effect immediately.# 当初从新加载特权表Reload privilege tables now? [Y/n] y ... Success!Cleaning up...All done! If you've completed all of the above steps, your MariaDBinstallation should now be secure.Thanks for using MariaDB!4、以root身份登录要从命令行与MariaDB服务器进行交互,请应用mysql客户端实用程序或其别名mariadb。此工具是作为MariaDB服务器软件包的依赖项装置的。
...