安装 Percona Yum 存储库
安装 Percona Server for MySQL 有多种方法。
我们可以使用 RPM、源代码或者官方 Yum 存储库安装它。
由于我们正在使用基于 Red Hat 的 Linux 发行版,因此,最方便的方法是从他们的官方 yum 存储库中安装它。
因此,我们需要在 Linux 服务器中安装 Percona yum 存储库。
# dnf install -y https://repo.percona.com/yum/percona-release-latest.noarch.rpm
Percona yum 存储库还安装了 percona-release 脚本。
此脚本用于启用/禁用其他 yum 存储库。
执行以下命令启用 Percona 服务器 8.0 存储库并禁用所有其他 MySQL yum 存储库。
# percona-release setup ps80
为新安装的 yum 存储库构建缓存。
# dnf makecache CentOS-8 - AppStream 3.6 kB/s | 4.3 kB 00:01 CentOS-8 - Base 3.5 kB/s | 3.9 kB 00:01 CentOS-8 - Extras 1.2 kB/s | 1.5 kB 00:01 Percona Release release/noarch YUM repository 4.3 kB/s | 2.9 kB 00:00 Percona Server 8.0 release/x86_64 YUM repositor 4.4 kB/s | 2.9 kB 00:00 Percona Tools release/x86_64 YUM repository 4.1 kB/s | 2.9 kB 00:00 Metadata cache created.
什么是 MySQL 的 Percona 服务器?
Percona Server for MySQL 是由 Percona 创建的开源关系数据库管理系统 (RDBMS)。
它是 Oracle MySQL 的免费、完全兼容的替代品。
该软件包括许多仅在 MySQL 的商业企业版中可用的可扩展性、可用性、安全性和备份功能。
该软件包括 XtraDB ,这是 InnoDB 存储引擎的增强版。
开发人员旨在保持与官方 MySQL 版本的密切兼容性,同时专注于性能和提高对服务器操作的可见性。
Percona Server 是 MySQL RDBMS 的一个发行版。
在本文中,我们将看到如何在 CentOS/RHEL 8 上安装此数据库服务器。
在 CentOS/RHEL 8 上安装 Percona Server for MySQL
我们现在可以使用 dnf 命令安装 Percona RDBMS。
# dnf install -y percona-server-server
启用并启动 mysqld.service。
# systemctl enable --now mysqld.service Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service -> /usr/lib/systemd/system/mysqld.service.
验证数据库服务器的版本。
# mysql -V mysql Ver 8.0.21-12 for Linux on x86_64 (Percona Server (GPL), Release 12, Revision 7ddfdfe)
首次启动时,mysqld.service 为 root 用户生成一个随机密码。
我们可以通过执行以下命令从 mysqld.service 日志中获取自动生成的 root 密码。
# grep "temporary password" /var/log/mysqld.log 2020-11-20T15:48:32.560387Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: cjk-4sB/bWWt
通过执行 mysql_secure_installation 命令来保护数据库机器,并按如下方式配置安全选项。
# mysql_secure_installation Securing the MySQL server deployment. Enter password for user root: The existing password for the user account root has expired. Please set a new password. New password: Re-enter new password: The 'validate_password' component is installed on the server. The subsequent steps will run with the existing configuration of the component. Using existing password for root. Estimated strength of the password: 100 Change the password for root ? ((Press y|Y for Yes, any other key for No) : N ... skipping. By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL 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? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : Y Success. By default, MySQL 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? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : Y Success. All done!
Percona Server for MySQL 已在 Linux 机器上安装和配置。
以 root 用户身份登录 MySQL shell。
# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 22 Server version: 8.0.21-12 Percona Server (GPL), Release 12, Revision 7ddfdfe Copyright (c) 2009-2020 Percona LLC and/or its affiliates Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
列出服务器中可用的数据库。
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.01 sec)
检查数据库服务器的版本。
mysql> select version(); +-----------+ | version() | +-----------+ | 8.0.21-12 | +-----------+ 1 row in set (0.00 sec)
退出 MySQL shell。
mysql> exit Bye