如何在 Ubuntu 22.04 LTS Linux 上安装 MySQL 服务器
教程详细信息 | |
---|---|
难度等级 | 简单的 |
Root 权限 | 是的 |
要求 | Linux 终端 |
类别 | 数据库服务器 |
操作系统兼容性 | Linux • Pop!_OS • Ubuntu |
预计阅读时间 | 15 分钟 |
步骤 1 – 更新系统
通过运行以下apt 命令来修补系统非常重要:
$ sudo apt update
$ sudo apt list --upgradable # get a list of upgrades
$ sudo apt upgrade
使用 APT 更新系统(点击放大)
第 2 步 - 在 Ubuntu 22.04 LTS 上搜索 MySQL 8 服务器包
使用 apt-cache 命令或apt 命令如下来搜索 Ubuntu 22.04 LTS 上的 MySQL 服务器和客户端软件包。例如:
$ apt-cache search mysql-server
系统将返回可用选项列表,包括 Ubuntu 22.04 LTS 上的 Oracle MySQL 8.xx 和 MariaDB 10.x 服务器和客户端:
mysql-server - MySQL database server (metapackage depending on the latest version) mysql-server-8.0 - MySQL database server binaries and system database setup mysql-server-core-8.0 - MySQL database server binaries default-mysql-server - MySQL database server binaries and system database setup (metapackage) default-mysql-server-core - MySQL database server binaries (metapackage) mariadb-server-10.6 - MariaDB database server binaries mariadb-server-core-10.6 - MariaDB database core server files
想要了解有关名为“mysql-server-8.0”的 MySQL 服务器包的更多信息?在 Ubuntu 22.04 上安装 mysql 之前,请在 Ubuntu 22.04 LTS 机器上尝试如下apt 命令:
$ apt info -a mysql-server-8.0
Package: mysql-server-8.0 Version: 8.0.29-0ubuntu0.22.04.2 Priority: optional Section: database Source: mysql-8.0 Origin: Ubuntu Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> Original-Maintainer: Debian MySQL Maintainers <pkg-mysql-maint@lists.alioth.debian.org> Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 1610 kB Provides: virtual-mysql-server Pre-Depends: adduser (>= 3.40), debconf, mysql-common (>= 5.5) Depends: lsb-base (>= 3.0-10), mysql-client-8.0 (>= 8.0.29-0ubuntu0.22.04.2), mysql-common (>= 5.8+1.0.4~), mysql-server-core-8.0 (= 8.0.29-0ubuntu0.22.04.2), passwd, perl:any (>= 5.6), psmisc, debconf (>= 0.5) | debconf-2.0 Recommends: libhtml-template-perl, mecab-ipadic-utf8 Suggests: mailx, tinyca Conflicts: mariadb-server-10.1, mariadb-server-10.3, mysql-server-5.7, virtual-mysql-server Homepage: http://dev.mysql.com/ Task: lamp-server Download-Size: 1391 kB APT-Sources: http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages Description: MySQL database server binaries and system database setup MySQL is a fast, stable and true multi-user, multi-threaded SQL database server. SQL (Structured Query Language) is the most popular database query language in the world. The main goals of MySQL are speed, robustness and ease of use. . This package contains all the infrastructure needed to setup system databases. Package: mysql-server-8.0 Version: 8.0.28-0ubuntu4 Priority: optional Section: database Source: mysql-8.0 Origin: Ubuntu Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> Original-Maintainer: Debian MySQL Maintainers <pkg-mysql-maint@lists.alioth.debian.org> Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 1603 kB Provides: virtual-mysql-server Pre-Depends: adduser (>= 3.40), debconf, mysql-common (>= 5.5) Depends: lsb-base (>= 3.0-10), mysql-client-8.0 (>= 8.0.28-0ubuntu4), mysql-common (>= 5.8+1.0.4~), mysql-server-core-8.0 (= 8.0.28-0ubuntu4), passwd, perl:any (>= 5.6), psmisc, debconf (>= 0.5) | debconf-2.0 Recommends: libhtml-template-perl, mecab-ipadic-utf8 Suggests: mailx, tinyca Conflicts: mariadb-server-10.1, mariadb-server-10.3, mysql-server-5.7, virtual-mysql-server Homepage: http://dev.mysql.com/ Task: lamp-server Download-Size: 1386 kB APT-Sources: http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages Description: MySQL database server binaries and system database setup MySQL is a fast, stable and true multi-user, multi-threaded SQL database server. SQL (Structured Query Language) is the most popular database query language in the world. The main goals of MySQL are speed, robustness and ease of use. . This package contains all the infrastructure needed to setup system databases.
mysql-server-8.0 与 mysql-server-core-8.0 包:
- mysql-server-8.0 – 几乎在所有情况下,您都需要此包。它包含 MySQL 数据库服务器二进制文件、客户端和系统数据库设置。
- mysql-server-core-8.0 – 此软件包包含服务器二进制文件,但不包含设置系统数据库所需的所有基础结构。因此,对于那些设置 Linux 容器(Docker、LXD 等)且不需要 mysql 客户端等所有内容的人来说,这个软件包更有用。
步骤 3 - 安装 MySQL 8 服务器包
让我们在 Ubuntu 22.04 LTS 上安装 MySQL 服务器版本 8.0.28:
$ sudo apt install mysql-server-8.0
示例会话:
Reading package lists... Done Building dependency tree... Done Reading state information... Done The following package was automatically installed and is no longer required: libfreetype6 Use 'apt autoremove' to remove it. The following additional packages will be installed: libcgi-fast-perl libcgi-pm-perl libclone-perl libencode-locale-perl libevent-pthreads-2.1-7 libfcgi-bin libfcgi-perl libfcgi0ldbl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl liblwp-mediatypes-perl libmecab2 libprotobuf-lite23 libtimedate-perl liburi-perl mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client-8.0 mysql-client-core-8.0 mysql-common mysql-server-core-8.0 Suggested packages: libdata-dump-perl libipc-sharedcache-perl libbusiness-isbn-perl libwww-perl mailx tinyca The following NEW packages will be installed: libcgi-fast-perl libcgi-pm-perl libclone-perl libencode-locale-perl libevent-pthreads-2.1-7 libfcgi-bin libfcgi-perl libfcgi0ldbl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl liblwp-mediatypes-perl libmecab2 libprotobuf-lite23 libtimedate-perl liburi-perl mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client-8.0 mysql-client-core-8.0 mysql-common mysql-server-8.0 mysql-server-core-8.0 0 upgraded, 27 newly installed, 0 to remove and 0 not upgraded. Need to get 28.6 MB of archives. After this operation, 240 MB of additional disk space will be used. Do you want to continue? [Y/n] y
设置 root 账户密码
首先,设置root账户的密码,运行:
$ sudo mysql
然后使用以下语法进行设置:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'My7Pass@Word_9_8A_zE'; exit
MySQL 8.xx 基本配置文件和端口
- mysql.service – 服务名称。您可以使用以下 systemctl 命令来控制它:
$ sudo systemctl start mysql.service
$ sudo systemctl stop mysql.service
$ sudo systemctl restart mysql.service
$ sudo systemctl status mysql.service - /etc/mysql/ – 主 MySQL 服务器配置目录。
- /etc/mysql/my.cnf – MySQL 数据库服务器配置文件。编辑.my.cnf ($HOME/.my.cnf) 以设置用户特定选项。可以从以下两个目录中覆盖的其他设置:
/etc/mysql/conf.d/
/etc/mysql/mysql.conf.d/ - TCP/3306 端口– TCP/3306 是 MySQL 服务器的默认网络,出于安全原因绑定到 127.0.0.1。但是,如果您需要 VLAN 或 VPN CIDR 访问,则可以更改它。然后,您可以使用 /run/mysqld/ 目录中设置的 localhost 套接字访问 MySQL 服务器。
步骤 4 – 保护 MySQL 8 服务器
默认情况下没有密码,其他设置需要调整。让我们运行以下命令并为我们设置和保护一些东西:
$ sudo mysql_secure_installation
默认情况下没有密码,其他设置需要调整。因此,让我们运行以下命令并为我们设置和保护一些东西(查找我的红色输入):
Securing the MySQL server deployment. Enter password for user root: My7Pass@Word_9_8A_zE VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component? Press y|Y for Yes, any other key for No: Y There are three levels of password validation policy: LOW Length >= 8 MEDIUM Length >= 8, numeric, mixed case, and special characters STRONG Length >= 8, numeric, mixed case, special characters and dictionary file Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2 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) : Y New password: My7Pass@Word_9_8A_zE Re-enter new password: My7Pass@Word_9_8A_zE Estimated strength of the password: 100 Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y
接下来,我将删除一个匿名用户,禁用远程 root 登录,并删除测试数据库:
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!
步骤 5 - 在启动时启用 MySQL 服务器
使用 systemctl 命令确保我们的 MySQL 服务器 8 在系统启动时启动:
$ sudo systemctl is-enabled mysql.service
如果未启用,请键入以下命令来启用服务器:
$ sudo systemctl enable mysql.service
通过键入以下 systemctl 命令在 Ubuntu Linux 20.04 LTS 上验证 MySQL 8 服务器状态:
$ sudo systemctl status mysql.service
输出:
● mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2022-08-10 23:46:30 UTC; 2min 19s ago Process: 1498 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS) Main PID: 1506 (mysqld) Status: "Server is operational" Tasks: 39 (limit: 4575) Memory: 361.5M CPU: 1.090s CGroup: /system.slice/mysql.service └─1506 /usr/sbin/mysqld Aug 10 23:46:30 example-mysql-8 systemd[1]: Starting MySQL Community Server... Aug 10 23:46:30 example-mysql-8 systemd[1]: Started MySQL Community Server.
步骤 6 - 启动/停止/重新启动 MySQL 服务器
使用命令行选项,我们可以控制 Ubuntu 22.04 LTS 上的 MySQL 服务器。如果服务器尚未运行,让我们启动它:
$ sudo systemctl start mysql.service
停止MySQL服务器,输入:
$ sudo systemctl stop mysql.service
重新启动 MySQL 服务器,如下所示:
$ sudo systemctl restart mysql.service
我们可以使用 journalctl 命令查看 MySQL 服务日志,如下所示:
$ sudo journalctl -u mysql.service -xe
输出:
May 10 05:09:01 ubuntu-example systemd[1]: Starting MySQL Community Server... ░░ Subject: A start job for unit mysql.service has begun execution ░░ Defined-By: systemd ░░ Support: http://www.ubuntu.com/support ░░ ░░ A start job for unit mysql.service has begun execution. ░░ ░░ The job identifier is 597. May 10 05:09:01 ubuntu-example systemd[1]: Started MySQL Community Server. ░░ Subject: A start job for unit mysql.service has finished successfully ░░ Defined-By: systemd ░░ Support: http://www.ubuntu.com/support ░░ ░░ A start job for unit mysql.service has finished successfully. ░░ ░░ The job identifier is 597.
默认错误日志文件设置为 /var/log/mysql/error.log,可以使用 tail 命令查看它或使用grep / egrep 命令查询或使用cat /more 和 less 命令:
$ sudo tail -f /var/log/mysql/error.log
示例输出:
2022-05-10T05:08:59.396952Z 7 [System] [MY-013172] [Server] Received SHUTDOWN from user boot. Shutting down mysqld (Version: 8.0.29-0ubuntu0.22.04.2). 2022-05-10T05:08:59.399628Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '127.0.0.1' port: 33060, socket: /var/run/mysqld/mysqlx.sock 2022-05-10T05:09:00.873507Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.29-0ubuntu0.22.04.2) (Ubuntu). 2022-05-10T05:09:01.640964Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.29-0ubuntu0.22.04.2) starting as process 1463 2022-05-10T05:09:01.652378Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2022-05-10T05:09:01.771700Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2022-05-10T05:09:01.942385Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. 2022-05-10T05:09:01.942503Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel. 2022-05-10T05:09:01.974967Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.29-0ubuntu0.22.04.2' socket: '/var/run/mysqld/mysqld.sock' port: 3306 (Ubuntu). 2022-05-10T05:09:01.974988Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '127.0.0.1' port: 33060, socket: /var/run/mysqld/mysqlx.sock
步骤 7 – 登录 MySQL 8 服务器进行测试
到目前为止,我们已经学习了如何在 Ubuntu 22.04 LTS 上安装、设置、保护和启动/停止 MySQL 服务器版本 8。接下来,是时候以 root(MySQL 管理员)用户身份登录了。语法是:
示例会话:
$ mysql -u {user} -p
$ mysql -u {user} -h {remote_server_ip} -p
$ mysql -u root -p
Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 14 Server version: 8.0.30-0ubuntu0.22.04.1 (Ubuntu) Copyright (c) 2000, 2022, Oracle and/or its affiliates. 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>
接下来,运行 STATUS 命令显示有关 MySQL 服务器的版本和其他信息:
STATUS;
输出:
mysql Ver 8.0.30-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu)) Connection id: 14 Current database: Current user: root@localhost SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server version: 8.0.30-0ubuntu0.22.04.1 (Ubuntu) Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: utf8mb4 Db characterset: utf8mb4 Client characterset: utf8mb4 Conn. characterset: utf8mb4 UNIX socket: /var/run/mysqld/mysqld.sock Binary data as: Hexadecimal Uptime: 5 min 40 sec Threads: 2 Questions: 20 Slow queries: 0 Opens: 142 Flush tables: 3 Open tables: 61 Queries per second avg: 0.058 --------------
我们可以看到MySQL版本如下:
SHOW VARIABLES LIKE "%version%";
输出:
+--------------------------+-------------------------+ | Variable_name | Value | +--------------------------+-------------------------+ | admin_tls_version | TLSv1.2,TLSv1.3 | | immediate_server_version | 999999 | | innodb_version | 8.0.30 | | original_server_version | 999999 | | protocol_version | 10 | | replica_type_conversions | | | slave_type_conversions | | | tls_version | TLSv1.2,TLSv1.3 | | version | 8.0.30-0ubuntu0.22.04.1 | | version_comment | (Ubuntu) | | version_compile_machine | x86_64 | | version_compile_os | Linux | | version_compile_zlib | 1.2.12 | +--------------------------+-------------------------+ 13 rows in set (0.00 sec)
步骤 8 - 创建新的 MySQL 数据库和用户/密码
让我们创建一个名为 mydemodb 的新数据库,输入:
CREATE DATABASE mydemodb;
接下来,我将为名为 mydemodb 的数据库创建一个名为“vivekappusr”的新用户,如下所示,密码为“aa09dd995C72_5355a598fc7D8ab1230a”:
CREATE USER 'vivekappusr'@'%' IDENTIFIED BY 'aa09dd995C72_5355a598fc7D8ab1230a';
最后授予权限:
GRANT SELECT, INSERT, UPDATE, DELETE ON mydemodb.* TO 'vivekappusr'@'%';
当然,我也可以授予所有特权,如下所示:
GRANT ALL PRIVILEGES ON mydemodb.* TO 'vivekappusr'@'%';
查看 MySQL 用户及其授权:
SELECT USER,host FROM mysql.user; SHOW GRANTS FOR vivekappusr;
测试如下:
其中,
$ mysql -u vivekappusr -p mydemodb
$ mysql -u vivekappusr -h localhost -p mydemodb
- -u vivekappusr: 登录用户
- -h localhost:连接到名为 localhost 的主机
- -p:提示输入密码
- mydemodb:连接到名为 mydemodb 的数据库
在 Ubuntu Linux 20.04 LTS 上运行的 MySQL 8 上创建用户和数据库(点击放大)
步骤 9 – MySQL 8 服务器配置
使用文本编辑器编辑/etc/mysql/mysql.conf.d/mysqld.cnf。例如:根据需要在部分
$ sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
下添加或编辑并设置默认值(有关各种配置选项的详细说明,请参阅https://dev.mysql.com/doc/):mysqld]
[mysqld] pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock datadir = /var/lib/mysql log-error = /var/log/mysql/error.log
接下来,我将启用网络访问:
# server LAN/VLAN IP and port bind_address = 10.147.164.6 port = 3306 skip_external_locking skip_name_resolve max_allowed_packet = 256M max_connect_errors = 1000000
微调设置:
# InnoDB default_storage_engine = InnoDB innodb_buffer_pool_instances = 1 innodb_buffer_pool_size = 512M innodb_file_per_table = 1 innodb_flush_log_at_trx_commit = 0 innodb_flush_method = O_DIRECT innodb_log_buffer_size = 16M innodb_log_file_size = 512M innodb_stats_on_metadata = 0 innodb_read_io_threads = 64 innodb_write_io_threads = 64 # MyISAM Settings (set if you are using MyISAM) key_buffer_size = 32M low_priority_updates = 1 concurrent_insert = 2 # Connection Settings max_connections = 100 back_log = 512 thread_cache_size = 100 thread_stack = 192K interactive_timeout = 180 wait_timeout = 180 # Buffer Settings join_buffer_size = 4M read_buffer_size = 3M read_rnd_buffer_size = 4M sort_buffer_size = 4M
根据您的需要进行一些表格设置:
# Table Settings (see below for open file limits) table_definition_cache = 40000 table_open_cache = 40000 open_files_limit = 60000 max_heap_table_size = 128M tmp_table_size = 128M # Search Settings ft_min_word_len = 3
根据您的需要启用日志记录:
# Logging log_error = /var/lib/mysql/mysql_error.log log_queries_not_using_indexes = 1 long_query_time = 5 slow_query_log = 0 # Disabled for production slow_query_log_file = /var/lib/mysql/mysql_slow.log
调整 mysqldum 进行备份:
[mysqldump]
quick
quote_names
max_allowed_packet
设置打开文件(文件描述符的数量)
对于繁忙的 MySQL 8 服务器,您需要使用 systemd 设置最大打开文件设置。否则,您将收到错误 Could not increase the number of max_open_files to more than XXXX。因此,运行:
$ sudo systemctl edit mysql.service
您将设置以下文本:
### Editing /etc/systemd/system/mysql.service.d/override.conf ### Anything between here and the comment below will become the new contents of the file ### Lines below this comment will be discarded ### /lib/systemd/system/mysql.service # # MySQL systemd service file # # [Unit] # Description=MySQL Community Server # After=network.target # # [Install] # WantedBy=multi-user.target # # [Service] # Type=notify # User=mysql # Group=mysql # PIDFile=/run/mysqld/mysqld.pid # PermissionsStartOnly=true # ExecStartPre=/usr/share/mysql/mysql-systemd-start pre # ExecStart=/usr/sbin/mysqld # TimeoutSec=infinity # Restart=on-failure # RuntimeDirectory=mysqld # RuntimeDirectoryMode=755 # LimitNOFILE=10000 # # # Set enviroment variable MYSQLD_PARENT_PID. This is required for restart. # Environment=MYSQLD_PARENT_PID=1
因此在之间添加您的配置:
### Anything between here and the comment below will become the new contents of the file ### Lines below this comment will be discarded
例如(将 1800000 替换为您想要的值。要获得最大支持值,请使用 代替LimitNOFILE=infinity)LimitNOFILE=1800000:
### Editing /etc/systemd/system/mysql.service.d/override.conf ### Anything between here and the comment below will become the new contents of the file [Service] LimitNOFILE=1800000 ### Lines below this comment will be discarded ### /lib/systemd/system/mysql.service # # MySQL systemd service file # # [Unit] # Description=MySQL Community Server # After=network.target # # [Install] # WantedBy=multi-user.target # # [Service] # Type=notify # User=mysql # Group=mysql # PIDFile=/run/mysqld/mysqld.pid # PermissionsStartOnly=true # ExecStartPre=/usr/share/mysql/mysql-systemd-start pre # ExecStart=/usr/sbin/mysqld # TimeoutSec=infinity # Restart=on-failure # RuntimeDirectory=mysqld # RuntimeDirectoryMode=755 # LimitNOFILE=10000 # # # Set enviroment variable MYSQLD_PARENT_PID. This is required for restart. # Environment=MYSQLD_PARENT_PID=1
创建或编辑 /etc/sysctl.d/100-custom.conf 并添加:
fs.nr_open=1800000
更新更改:
$ sudo sysctl -p /etc/sysctl.d/100-custom.conf
然后重新加载并重新启动 mysql 服务:
验证它:
示例输出:
$ sudo systemctl daemon-reload
$ sudo systemctl restart mysql
$ mysql -u root -p -e 'SHOW GLOBAL VARIABLES LIKE "open_files_limit";'
+------------------+---------+ | Variable_name | Value | +------------------+---------+ | open_files_limit | 1800000 | +------------------+---------+
您还可以使用以下命令查询 Ubuntu 22.04 LTS 下 MySQL 服务器当前的打开文件限制:
输出:
$ cat /proc/$(cat /var/run/mysqld/mysqld.pid)/limits
## OR ##
$ grep 'open files' /proc/$(cat /var/run/mysqld/mysqld.pid)/limits
Max open files 1800000 1800000 files
您还可以使用 prlimit 命令,如下所示:
mysql 服务器的 LIMITS:
# prlimit -p $(</var/run/mysqld/mysqld.pid)
# prlimit -p $(</var/run/mysqld/mysqld.pid) | grep 'open'
RESOURCE DESCRIPTION SOFT HARD UNITS AS address space limit unlimited unlimited bytes CORE max core file size 0 unlimited bytes CPU CPU time unlimited unlimited seconds DATA max data size unlimited unlimited bytes FSIZE max file size unlimited unlimited bytes LOCKS max number of file locks held unlimited unlimited locks MEMLOCK max locked-in-memory address space 65536 65536 bytes MSGQUEUE max bytes in POSIX mqueues 819200 819200 bytes NICE max nice prio allowed to raise 0 0 NOFILE max number of open files 1800000 1800000 files NPROC max number of processes 63498 63498 processes RSS max resident set size unlimited unlimited bytes RTPRIO max real-time priority 0 0 RTTIME timeout for real-time tasks unlimited unlimited microsecs SIGPENDING max number of pending signals 63498 63498 signals STACK max stack size 8388608 unlimited bytes
总结
至此,Oracle MySQL 服务器版本 8.x 已在 Ubuntu Linux 22.04 LTS 服务器上正确设置并运行。此外,您还学习了如何为项目添加新数据库、用户、密码以及微调服务器配置。请参阅 Oracle MySQL 数据库文档以了解 SQL 和其他命令。