通过以root或具有sudo权限的用户身份使用CentOS软件包来安装MySQL 8.0
<code># sudo dnf install @mysql/<code>
@mysql模块将安装MySQL及其所有依赖项。
安装完成后,通过运行以下命令来启动MySQL服务并使它在启动时自动运行:
<code># systemctl start mysqld# systemctl enable --now mysqld/<code>
要检查MySQL服务器是否正在运行,请输入:
<code># systemctl status mysqld/<code>
显示样例:
<code>mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Sun 2020-2-12 06:07:35 UTC; 1min 59s ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 4633 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 4708 (mysqld) Status: "Server is operational" Tasks: 38 (limit: 9584) Memory: 496.4M CGroup: /system.slice/mysqld.service └─4708 /usr/sbin/mysqldFeb 12 06:07:23 centos8 systemd[1]: Starting MySQL Server...Feb 12 06:07:35 centos8 systemd[1]: Started MySQL Server./<code>
安全设置:
<code># mysql_secure_installation/<code>
进入MySQL
<code># mysql -u root -p/<code>
<code>Enter password: << 输入 MySQL Root 密码Welcome to the MySQL monitor. Commands end with ; or \\g.Your MySQL connection id is 12Server version: 8.0.13 Source distributionCopyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.mysql>/<code>
![如何在CentOS 8上安装MySQL 8.0](http://p2.ttnews.xyz/loading.gif)
这样就可以啦!
閱讀更多 多青科技 的文章