本文介绍在Ubuntu 20.04(Focal Fossa)服务器上安装MariaDB 10.5数据库的方法。要在Ubuntu 20.04上安装MariaDB 10.5,您需要在系统上添加MariaDB存储库,然后将在添加的APT存储库中完成Ubuntu 20.04上MariaDB 10.5的安装,这样一般不会出现任何问题。
步骤1:更新Ubuntu 20.04系统 确保Ubuntu 20.04系统已更新,并安装software-properties-common软件包: sudo apt update && sudo apt upgrade sudo apt -y install software-properties-common
步骤2:导入MariaDB gpg密钥 运行以下命令以将存储库密钥添加到Ubuntu 20.04系统: sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
步骤3:添加MariaDB APT存储库 导入存储库GPG密钥后,通过运行以下命令来添加APT存储库: sudo add-apt-repository 'deb [arch=amd64] http://mariadb.mirror.globo.tech/repo/10.5/ubuntu focal main' 注:以上10.5代表是MariaDB 10.5版本,而focal代表是Ubuntu 20.04(Focal Fossa)。 命令执行输出: Hit:1 http://security.ubuntu.com/ubuntu focal-security InRelease Hit:2 http://nova.clouds.archive.ubuntu.com/ubuntu focal InRelease Get:3 http://mariadb.mirror.globo.tech/repo/10.5/ubuntu focal InRelease [3202 B] Hit:4 http://nova.clouds.archive.ubuntu.com/ubuntu focal-updates InRelease Hit:5 http://nova.clouds.archive.ubuntu.com/ubuntu focal-backports InRelease Get:6 http://mariadb.mirror.globo.tech/repo/10.5/ubuntu focal/main amd64 Packages [7924 B] Fetched 11.1 kB in 1s (15.6 kB/s) Reading package lists... Done
步骤4:在Ubuntu 20.04上安装MariaDB Server 最后一步是安装MariaDB Server: sudo apt update sudo apt install mariadb-server mariadb-client 按y键以接受在Ubuntu 20.04 Linux上安装MariaDB 10.5。 将安装以下附加软件包,如下: galera-4 libcgi-fast-perl libcgi-pm-perl libdbd-mariadb-perl libdbi-perl libencode-locale-perl libfcgi-perl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl liblwp-mediatypes-perl libmariadb3 libmysqlclient21 libterm-readkey-perl libtimedate-perl liburi-perl mariadb-client-10.5 mariadb-client-core-10.5 mariadb-common mariadb-server-10.5 mariadb-server-core-10.5 mysql-common socat Suggested packages: libclone-perl libmldbm-perl libnet-daemon-perl libsql-statement-perl libdata-dump-perl libipc-sharedcache-perl libwww-perl mailx mariadb-test tinyca The following NEW packages will be installed: galera-4 libcgi-fast-perl libcgi-pm-perl libdbd-mariadb-perl libdbi-perl libencode-locale-perl libfcgi-perl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl liblwp-mediatypes-perl libmariadb3 libmysqlclient21 libterm-readkey-perl libtimedate-perl liburi-perl mariadb-client mariadb-client-10.5 mariadb-client-core-10.5 mariadb-common mariadb-server mariadb-server-10.5 mariadb-server-core-10.5 mysql-common socat 0 upgraded, 28 newly installed, 0 to remove and 0 not upgraded. Need to get 29.5 MB of archives. After this operation, 229 MB of additional disk space will be used. Do you want to continue? [Y/n] y 参考:在Ubuntu 20.04(Focal Fossa)上安装LAMP(Apache、MariaDB、PHP)。
步骤5:在Ubuntu 20.04上保护MariaDB服务器 您必须手动运行MySQL强化脚本: $ sudo mysql_secure_installation NOTE: 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 current password for the root user. If you've just installed MariaDB, and haven't set the root password yet, you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password or using the unix_socket ensures that nobody can log into the MariaDB root user without the proper authorisation. You already have your root account protected, so you can safely answer 'n'. Switch to unix_socket authentication [Y/n] y Enabled successfully! Reloading privilege tables.. ... Success! You already have your root account protected, so you can safely answer 'n'. Change the root password? [Y/n] y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will 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 MariaDB installation should now be secure. Thanks for using MariaDB! 安装后应自动启动数据库服务: $ systemctl status mysql
注:所安装的版本是MariaDB 10.5.2。 使用mysql命令测试对MariaDB Shell的登录: $ mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 56 Server version: 10.5.2-MariaDB-1:10.5.2+maria~focal-log mariadb.org binary distribution 使用以下命令检查版本: MariaDB [(none)]> SELECT VERSION();
注:如上图所示,MariaDB的版本是10.5.2。
相关主题 |