怎样在Ubuntu上安装MariaDB10

2022年11月18日 | 分类: 【技术】

参考:https://zhuanlan.zhihu.com/p/141988967

【安装】

安装 Ubuntu 软件源仓库中的 MariaDB 。

sudo apt install mariadb-server

一旦安装完成,MariaDB 服务将会自动启动。

查看状态:

sudo systemctl status mariadb

输出:

● mariadb.service - MariaDB 10.6.7 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2022-11-18 08:20:54 UTC; 1min 2s ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 1729 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
    Process: 1730 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 1732 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, stat>
    Process: 1773 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 1775 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
   Main PID: 1761 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 9 (limit: 2256)
     Memory: 57.2M
        CPU: 607ms
     CGroup: /system.slice/mariadb.service
             └─1761 /usr/sbin/mariadbd

输出信息中 active (running) 显示服务已经启用,并且正在运行。

【设置】

开启开机启动:

sudo systemctl enable --now mariadb

启动服务:

sudo systemctl start mariadb.service

查看服务状态:

sudo systemctl status mariadb

初始设置:

sudo mysql_secure_installation

#输入root(mysql)的密码。默认没有,直接回车
Enter current password for root (enter for none):
#是否切换到unix套接字身份验证[Y/n] unix_socket 可以让用户通过本地socket登陆而无需密码,据介绍,这种加密非常安全可靠。
Switch to unix_socket authentication [Y/n] n
#是否设置root密码
Change the root password? [Y/n]
#如果选Y,就输入2次密码
New password:
Re-enter new password:
#是否删除匿名用户?(就是空用户),建议删除
Remove anonymous users? [Y/n]
#是否不允许远程root登录
Disallow root login remotely? [Y/n] n
#是否删除test数据库
Remove test database and access to it? [Y/n] n
#是否加载权限使之生效
Reload privilege tables now? [Y/n] y