centos8 rpm 安装mysql8.0.28

检查

检测系统是否自带安装 MySQL

命令如下:
rpm -qa | grep mysql
如果如下存在已安装的包,就需要卸载
mysql80-community-release-el8-1.noarch
mysql-community-client-8.0.18-1.el8.x86_64
mysql-community-libs-8.0.18-1.el8.x86_64
mysql-community-server-8.0.18-1.el8.x86_64
mysql-community-common-8.0.18-1.el8.x86_64

卸载命令

存在mysql已安装的包就需要依次卸载

rpm -e mysql  // 普通删除
rpm -e --nodeps mysql  // 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删

查看是否安装了mariadb;

rpm -qa | grep mariadb

如果有安装的话使用如下命令移除:

rpm -e XXX

rpm -e --nodeps xxx //强制删除

下载

官网地址

MySQL :: Download MySQL Community Server

下载 centos8 的

mysql-8.0.28-1.el8.x86_64.rpm-bundle.tar

使用浏览器自带下载功能下载有时候可能会出现因为网络等原因包下载不完整而出问题的情况(最好下载后校验哈希值),如若正常安装老是出问题,推荐使用迅雷等下载工具下载后校验完毕,使用FTP近程传输到服务器安装目录。

解压

[root@localhost rootftp]# ls
mysql-8.0.28-1.el8.x86_64.rpm-bundle.tar
mysql-community-client-8.0.28-1.el8.x86_64.rpm
mysql-community-client-debuginfo-8.0.28-1.el8.x86_64.rpm
mysql-community-client-plugins-8.0.28-1.el8.x86_64.rpm
mysql-community-client-plugins-debuginfo-8.0.28-1.el8.x86_64.rpm
mysql-community-common-8.0.28-1.el8.x86_64.rpm
mysql-community-debuginfo-8.0.28-1.el8.x86_64.rpm
mysql-community-debugsource-8.0.28-1.el8.x86_64.rpm
mysql-community-devel-8.0.28-1.el8.x86_64.rpm
mysql-community-icu-data-files-8.0.28-1.el8.x86_64.rpm
mysql-community-libs-8.0.28-1.el8.x86_64.rpm
mysql-community-libs-debuginfo-8.0.28-1.el8.x86_64.rpm
mysql-community-server-8.0.28-1.el8.x86_64.rpm
mysql-community-server-debug-8.0.28-1.el8.x86_64.rpm
mysql-community-server-debug-debuginfo-8.0.28-1.el8.x86_64.rpm
mysql-community-server-debuginfo-8.0.28-1.el8.x86_64.rpm
mysql-community-test-8.0.28-1.el8.x86_64.rpm
mysql-community-test-debuginfo-8.0.28-1.el8.x86_64.rpm
[root@localhost rootftp]#

安装

注意安装顺序

  • mysql-community-common
  • 三个一起装 因为 有依赖
    • mysql-community-libs-***.rpm
    • mysql-community-client-***.rpm
    • mysql-community-client-plugins-***.rpm
  • mysql-community-server-***.rpm
    • 因为依赖perl ,所以可以直接通过yum方式安装
    • yum install mysql-community-server-****.x86_64.rpm

本人采用的安装顺序,含最末回车符号批量复制进去可以实现一次性批处理安装至结束,直接接续配置步骤:

rpm -ivh mysql-community-common-8.0.28-1.el8.x86_64.rpm
rpm -ivh mysql-community-libs-debuginfo-8.0.28-1.el8.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.28-1.el8.x86_64.rpm
rpm -ivh mysql-community-client-plugins-debuginfo-8.0.28-1.el8.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.28-1.el8.x86_64.rpm
rpm -ivh mysql-community-client-8.0.28-1.el8.x86_64.rpm
rpm -ivh mysql-community-debuginfo-8.0.28-1.el8.x86_64.rpm
rpm -ivh mysql-community-client-debuginfo-8.0.28-1.el8.x86_64.rpm
rpm -ivh mysql-community-debugsource-8.0.28-1.el8.x86_64.rpm
rpm -ivh mysql-community-devel-8.0.28-1.el8.x86_64.rpm
rpm -ivh mysql-community-icu-data-files-8.0.28-1.el8.x86_64.rpm
rpm -ivh mysql-community-server-debug-8.0.28-1.el8.x86_64.rpm
rpm -ivh mysql-community-server-debug-debuginfo-8.0.28-1.el8.x86_64.rpm
rpm -ivh mysql-community-server-debuginfo-8.0.28-1.el8.x86_64.rpm
rpm -ivh mysql-community-test-8.0.28-1.el8.x86_64.rpm
rpm -ivh mysql-community-test-debuginfo-8.0.28-1.el8.x86_64.rpm
rpm -ivh mysql-community-server-8.0.28-1.el8.x86_64.rpm

ps: MySQL 8.0.34 安装顺序(操作系统为CentOS 9 Stream)

=========================CentOS 9 Stream===================

rpm -ivh mysql-community-common-8.0.34-1.el9.x86_64.rpm
rpm -ivh mysql-community-libs-debuginfo-8.0.34-1.el9.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.34-1.el9.x86_64.rpm
rpm -ivh mysql-community-client-plugins-debuginfo-8.0.34-1.el9.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.34-1.el9.x86_64.rpm
rpm -ivh mysql-community-client-8.0.34-1.el9.x86_64.rpm
rpm -ivh mysql-community-debuginfo-8.0.34-1.el9.x86_64.rpm
rpm -ivh mysql-community-client-debuginfo-8.0.34-1.el9.x86_64.rpm
rpm -ivh mysql-community-debugsource-8.0.34-1.el9.x86_64.rpm
rpm -ivh mysql-community-devel-8.0.34-1.el9.x86_64.rpm
rpm -ivh mysql-community-icu-data-files-8.0.34-1.el9.x86_64.rpm
rpm -ivh mysql-community-server-debug-8.0.34-1.el9.x86_64.rpm
rpm -ivh mysql-community-server-debug-debuginfo-8.0.34-1.el9.x86_64.rpm
rpm -ivh mysql-community-server-debuginfo-8.0.34-1.el9.x86_64.rpm
rpm -ivh mysql-community-test-8.0.34-1.el9.x86_64.rpm
rpm -ivh mysql-community-test-debuginfo-8.0.34-1.el9.x86_64.rpm
rpm -ivh mysql-community-server-8.0.34-1.el9.x86_64.rpm

=======================Oracle Linux /CentOS 8 =====================

rpm -ivh mysql-community-debuginfo-8.0.34-1.el8.x86_64.rpm
rpm -ivh mysql-community-common-8.0.34-1.el8.x86_64.rpm
rpm -ivh mysql-community-libs-debuginfo-8.0.34-1.el8.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.34-1.el8.x86_64.rpm
rpm -ivh mysql-community-client-plugins-debuginfo-8.0.34-1.el8.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.34-1.el8.x86_64.rpm
rpm -ivh mysql-community-client-8.0.34-1.el8.x86_64.rpm
rpm -ivh mysql-community-client-debuginfo-8.0.34-1.el8.x86_64.rpm
rpm -ivh mysql-community-debugsource-8.0.34-1.el8.x86_64.rpm
rpm -ivh mysql-community-devel-8.0.34-1.el8.x86_64.rpm
rpm -ivh mysql-community-icu-data-files-8.0.34-1.el8.x86_64.rpm
rpm -ivh mysql-community-server-8.0.34-1.el8.x86_64.rpm
rpm -ivh mysql-community-server-debug-8.0.34-1.el8.x86_64.rpm
rpm -ivh mysql-community-server-debug-debuginfo-8.0.34-1.el8.x86_64.rpm
rpm -ivh mysql-community-server-debuginfo-8.0.34-1.el8.x86_64.rpm
rpm -ivh mysql-community-test-8.0.34-1.el8.x86_64.rpm
rpm -ivh mysql-community-test-debuginfo-8.0.34-1.el8.x86_64.rpm

On the CentOS 9 Stream,  It may thread out Erorr message,like:

在CentOS 9 Stream上可能报如下错误:

warning: mysql-community-libs-compat-5.7.28-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
libcrypto.so.10()(64bit) is needed by mysql-community-libs-compat-5.7.28-1.el7.x86_64
libcrypto.so.10(libcrypto.so.10)(64bit) is needed by mysql-community-libs-compat-5.7.28-1.el7.x86_64
libssl.so.10()(64bit) is needed by mysql-community-libs-compat-5.7.28-1.el7.x86_64
libssl.so.10(libssl.so.10)(64bit) is needed by mysql-community-libs-compat-5.7.28-1.el7.x86_64 Just Like this , not exactly the same.

To deal with the error, you can try to add --nodeps --force after the "rpm -ivh ***" commond.

rpm -ivh mysql-community-common-8.0.28-1.el8.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-libs-debuginfo-8.0.28-1.el8.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-client-plugins-8.0.28-1.el8.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-client-plugins-debuginfo-8.0.28-1.el8.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-libs-8.0.28-1.el8.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-client-8.0.28-1.el8.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-debuginfo-8.0.28-1.el8.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-client-debuginfo-8.0.28-1.el8.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-debugsource-8.0.28-1.el8.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-devel-8.0.28-1.el8.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-icu-data-files-8.0.28-1.el8.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-server-debug-8.0.28-1.el8.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-server-debug-debuginfo-8.0.28-1.el8.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-server-debuginfo-8.0.28-1.el8.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-test-8.0.28-1.el8.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-test-debuginfo-8.0.28-1.el8.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-server-8.0.28-1.el8.x86_64.rpm --nodeps --force
[root@localhost rootftp]# rpm -ivh mysql-community-common-8.0.28-1.el8.x86_64.rpm
warning: mysql-community-common-8.0.28-1.el8.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-common-8.0.28-1.e################################# [100%]
[root@localhost rootftp]# rpm -ivh mysql-community-libs-debuginfo-8.0.28-1.el8.x86_64.rpm
warning: mysql-community-libs-debuginfo-8.0.28-1.el8.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
error: Failed dependencies:
mysql-community-debuginfo(x86-64) = 8.0.28-1.el8 is needed by mysql-community-libs-debuginfo-8.0.28-1.el8.x86_64
[root@localhost rootftp]# rpm -ivh mysql-community-client-plugins-8.0.28-1.el8.x86_64.rpm
warning: mysql-community-client-plugins-8.0.28-1.el8.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-client-plugins-8.################################# [100%]
[root@localhost rootftp]# rpm -ivh mysql-community-client-plugins-debuginfo-8.0.28-1.el8.x86_64.rpm
warning: mysql-community-client-plugins-debuginfo-8.0.28-1.el8.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
error: Failed dependencies:
mysql-community-debuginfo(x86-64) = 8.0.28-1.el8 is needed by mysql-community-client-plugins-debuginfo-8.0.28-1.el8.x86_64
[root@localhost rootftp]# rpm -ivh mysql-community-libs-8.0.28-1.el8.x86_64.rpm
warning: mysql-community-libs-8.0.28-1.el8.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-libs-8.0.28-1.el8################################# [100%]
[root@localhost rootftp]# rpm -ivh mysql-community-client-8.0.28-1.el8.x86_64.rpm
warning: mysql-community-client-8.0.28-1.el8.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-client-8.0.28-1.e################################# [100%]
[root@localhost rootftp]# rpm -ivh mysql-community-debuginfo-8.0.28-1.el8.x86_64.rpm
warning: mysql-community-debuginfo-8.0.28-1.el8.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-debuginfo-8.0.28-################################# [100%]
[root@localhost rootftp]# rpm -ivh mysql-community-client-debuginfo-8.0.28-1.el8.x86_64.rpm
warning: mysql-community-client-debuginfo-8.0.28-1.el8.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-client-debuginfo-################################# [100%]
[root@localhost rootftp]# rpm -ivh mysql-community-debugsource-8.0.28-1.el8.x86_64.rpm
warning: mysql-community-debugsource-8.0.28-1.el8.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-debugsource-8.0.2################################# [100%]
[root@localhost rootftp]# rpm -ivh mysql-community-devel-8.0.28-1.el8.x86_64.rpm
warning: mysql-community-devel-8.0.28-1.el8.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-devel-8.0.28-1.el################################# [100%]
[root@localhost rootftp]# rpm -ivh mysql-community-icu-data-files-8.0.28-1.el8.x86_64.rpm
warning: mysql-community-icu-data-files-8.0.28-1.el8.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-icu-data-files-8.################################# [100%]
[root@localhost rootftp]# rpm -ivh mysql-community-server-debug-8.0.28-1.el8.x86_64.rpm
warning: mysql-community-server-debug-8.0.28-1.el8.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
error: Failed dependencies:
mysql-community-server = 8.0.28-1.el8 is needed by mysql-community-server-debug-8.0.28-1.el8.x86_64
[root@localhost rootftp]# rpm -ivh mysql-community-server-debug-debuginfo-8.0.28-1.el8.x86_64.rpm
warning: mysql-community-server-debug-debuginfo-8.0.28-1.el8.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-server-debug-debu################################# [100%]
[root@localhost rootftp]# rpm -ivh mysql-community-server-debuginfo-8.0.28-1.el8.x86_64.rpm
warning: mysql-community-server-debuginfo-8.0.28-1.el8.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-server-debuginfo-################################# [100%]
[root@localhost rootftp]# rpm -ivh mysql-community-test-8.0.28-1.el8.x86_64.rpm
warning: mysql-community-test-8.0.28-1.el8.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
error: Failed dependencies:
mysql-community-server(x86-64) >= 8.0.11 is needed by mysql-community-test-8.0.28-1.el8.x86_64
perl(JSON) is needed by mysql-community-test-8.0.28-1.el8.x86_64
[root@localhost rootftp]# rpm -ivh mysql-community-test-debuginfo-8.0.28-1.el8.x86_64.rpm
warning: mysql-community-test-debuginfo-8.0.28-1.el8.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-test-debuginfo-8.################################# [100%]
[root@localhost rootftp]# rpm -ivh mysql-community-server-8.0.28-1.el8.x86_64.rpm
warning: mysql-community-server-8.0.28-1.el8.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-server-8.0.28-1.e################################# [100%]
[/usr/lib/tmpfiles.d/pesign.conf:1] Line references path below legacy directory /var/run/, updating /var/run/pesign → /run/pesign; please update the tmpfiles.d/ drop-in file accordingly.
[root@localhost rootftp]# yum install mysql-server
Last metadata expiration check: 1:37:35 ago on Thu 03 Mar 2022 03:07:09 AM EST.
Package mysql-community-server-8.0.28-1.el8.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
[root@localhost rootftp]# yum install mysql
Last metadata expiration check: 1:37:50 ago on Thu 03 Mar 2022 03:07:09 AM EST.
Package mysql-community-client-8.0.28-1.el8.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!

安装完成

  • 安装完成后,会自动生成 /etc/my.cnf 配置文件

  • 安装了 mysql-community-server 组件,会:
    a). 在 /etc/下生成 my.cnf 文件 和 my.cnf.d 文件夹

    b). 在/var/lib/下生产以下三个文件夹

    c). 在/var/log/ 下生成 mysqld.log 文件

    d). 在/var/run/ 下生成 mysqld 目录

  • [root@localhost rootftp]# cat /etc/my.cnf

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html [mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

启动mysql

[root@localhost rootftp]# systemctl start mysqld
[root@localhost rootftp]# systemctl status mysqld

● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor pres>
Active: active (running) since Thu 2022-03-03 04:46:34 EST; 20s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 41027 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=>
Main PID: 41061 (mysqld)
Status: "Server is operational"
Tasks: 38 (limit: 23385)
Memory: 471.0M
CGroup: /system.slice/mysqld.service
└─41061 /usr/sbin/mysqld Mar 03 04:46:27 localhost.localdomain systemd[1]: Starting MySQL Server...
Mar 03 04:46:34 localhost.localdomain systemd[1]: Started MySQL Server.

修改密码

  • 查看密码
grep 'temporary password' /var/log/mysqld.log
2022-03-03T07:10:39.887374Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: U<=VsitGY83w
mysql

修改密码

##  这里是个错误的示范,因为所输入的密码不符合mysql默认密码安全规则
[root@localhost rootftp]# mysql mysql> alter user 'root'@'localhost' identified by 'root';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> set global validate_password_length=1;
ERROR 1193 (HY000): Unknown system variable 'validate_password_length'
mysql> show global
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
mysql> SHOW VARIABLES LIKE 'validate_password%';
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. ## 提示:先按照默认密码规则设置并记住设置的密码,
### 密码组合最好是: 大写字母+数字+小写字母+特殊符号,
## 记下来,最好抄下来,忘记了会哭

mysql> ALTER USER 'root'@'localhost' identified by '12345678Aa?'; # 注意密码规则
Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; # 刷新权限规则
Query OK, 0 rows affected (0.00 sec) mysql> show variables like 'validate_password%';
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password.check_user_name | ON |
| validate_password.dictionary_file | |
| validate_password.length | 8 |
| validate_password.mixed_case_count | 1 |
| validate_password.number_count | 1 |
| validate_password.policy | MEDIUM |
| validate_password.special_char_count | 1 |
+--------------------------------------+--------+
7 rows in set (0.01 sec) mysql> set global validate_password.length=4; # 减少密码长度要求
Query OK, 0 rows affected (0.00 sec) mysql> set global validate_password.policy=0; # 取消密码验证策略
Query OK, 0 rows affected (0.00 sec) mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------+-------+
| validate_password.check_user_name | ON |
| validate_password.dictionary_file | |
| validate_password.length | 4 |
| validate_password.mixed_case_count | 1 |
| validate_password.number_count | 1 |
| validate_password.policy | LOW |
| validate_password.special_char_count | 1 |
+--------------------------------------+-------+
7 rows in set (0.00 sec) ### “新密码”即更新密码规则后自己设置的密码,
### 做了如上规则更改以后可以设置简单密码,诸如:123456
### 简单密码仅限于本地开发调试方便,
### 正式部署或生产环境时候必须按照密码规则设置复杂度足够和
### 符合密码规则和各种安全标准规范合规的密码,以增强系统的安全性
### 常见的安全标准规范如 GB强制的等级保护、分级保护之二、三、四级,以及企业或组织要求的规则等; mysql> ALTER USER 'root'@'localhost' identified by '新密码'; # 建议设置合规安全的密码,可以设置简单密码
Query OK, 0 rows affected (0.00 sec) mysql> exit
Bye
[root@192 home]# mysql -u root -p Enter password: # 输入新设置的密码登入
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.34 MySQL Community Server - GPL Copyright (c) 2000, 2023, 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> exit
Bye
[root@192 home]#
  • 问题 短密码不能设置,需要修改密码策略

    • set global validate_password.length=4; 密码长度改成4
    • set global validate_password.policy=0; 密码校验强度改成LOW后,只校验密码长度

查看当前安全变量值并修改

mysql> show variables like 'validate_password%';
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password.check_user_name | ON |
| validate_password.dictionary_file | |
| validate_password.length | 8 |
| validate_password.mixed_case_count | 1 |
| validate_password.number_count | 1 |
| validate_password.policy | MEDIUM |
| validate_password.special_char_count | 1 |
+--------------------------------------+--------+
7 rows in set (0.01 sec) mysql> set global validate_password.length=4;
Query OK, 0 rows affected (0.00 sec) mysql> set global validate_password.policy=0;
Query OK, 0 rows affected (0.00 sec) mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------+-------+
| validate_password.check_user_name | ON |
| validate_password.dictionary_file | |
| validate_password.length | 4 |
| validate_password.mixed_case_count | 1 |
| validate_password.number_count | 1 |
| validate_password.policy | LOW |
| validate_password.special_char_count | 1 |
+--------------------------------------+-------+
7 rows in set (0.00 sec)

设置开机启动

[root@192 home]# systemctl enable mysqld

=============以下内容与上文有所重复,仅供对比参考======

CentOS 9 Stream rpm 安装mysql8.0.29

    # !!!注意:以下参考除命令以外很多是说明文字,不要全部复制,自行选择该执行的命令
方法一(推荐):使用yum安装基础依赖并通过yum安装mysql-community-{server,client,common,libs}-*(亲测能解决所需依赖,正常安装)
# 如果系统提示类似“compat-openssl10 is needed”或者各种提示缺乏依赖的情况,可改用yum进行安装
yum install compat-openssl10
yum install http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/Packages/compat-openssl10-1.0.2o-3.el8.x86_64.rpm sudo yum update
sudo yum install mysql-community-{server,client,common,libs}-*
mysql # 方法二:官网下载mysql-8.0.29-1.el8.x86_64.rpm-bundle.tar 包解压安装,此种方法要注意解决提示的依赖项和rpm包的安装顺序。
[root@dz Downloads]#wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.29-1.el8.x86_64.rpm-bundle.tar
chmod 777 mysql-8.0.29-1.el8.x86_64.rpm-bundle.tar
tar -xvf mysql-8.0.29-1.el8.x86_64.rpm-bundle.tar #解压后会得到很多个mysql组件的rpm包
ls
# 检查系统中已经存在的mysql和mariadb并卸载干净
rpm -qa | grep mysql
rpm -e mysql80-community-release-el8-4.noarch
rpm -qa | grep mariadb
rpm -e
rpm -e mariadb-connector-c-config-3.2.6-1.el9.noarch
rpm -e
rpm -e mariadb-connector-c-3.2.6-1.el9.x86_64
rpm -e mariadb-connector-c-3.2.6-1.el9.x86_64 --nodeps
rpm -e mariadb-connector-c-config-3.2.6-1.el9.noarch --nodeps
rpm -ivh mysql-community-common-8.0.29-1.el8.x86_64.rpm
# 正式开始安装,此参考安装顺序有时候会提示缺乏依赖项,逐一解决后全部安装完才可以,比较麻烦
rpm -ivh mysql-community-libs-debuginfo-8.0.29-1.el8.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.29-1.el8.x86_64.rpm
rpm -ivh mysql-community-client-plugins-debuginfo-8.0.29-1.el8.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.29-1.el8.x86_64.rpm
rpm -ivh mysql-community-client-8.0.29-1.el8.x86_64.rpm
rpm -ivh mysql-community-debuginfo-8.0.29-1.el8.x86_64.rpm
rpm -ivh mysql-community-client-debuginfo-8.0.29-1.el8.x86_64.rpm
rpm -ivh mysql-community-debugsource-8.0.29-1.el8.x86_64.rpm
rpm -ivh mysql-community-devel-8.0.29-1.el8.x86_64.rpm
rpm -ivh mysql-community-icu-data-files-8.0.29-1.el8.x86_64.rpm
rpm -ivh mysql-community-server-debug-8.0.29-1.el8.x86_64.rpm
rpm -ivh mysql-community-server-debug-debuginfo-8.0.29-1.el8.x86_64.rpm
rpm -ivh mysql-community-server-debuginfo-8.0.29-1.el8.x86_64.rpm
rpm -ivh mysql-community-test-8.0.29-1.el8.x86_64.rpm
rpm -ivh mysql-community-test-debuginfo-8.0.29-1.el8.x86_64.rpm
rpm -ivh mysql-community-server-8.0.29-1.el8.x86_64.rpm # 安装完成后进行配置和修改管理密码 [root@dz]#cat /etc/my.cnf
clear
vi /etc/my.cnf cat /etc/my.cnf systemctl start mysqld ystemctl status mysqld stemctl status mysqld systemctl status mysqld grep 'temporary password' /var/log/mysqld.log
# 执行成功回显信息附带了临时密码,显示如下:
[root@dz Downloads]# grep 'temporary password' /var/log/mysqld.log
2022-07-05T07:15:05.672937Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: dz8>DAfTfwtM
# 其中,最末尾的字符串“dz8>DAfTfwtM”即为安装生成的临时密码,供修改密码使用 mysql systemctl status mysqld
# 此命令执行后应该返回如下:active(running)状态为绿色
[root@dz Downloads]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2022-07-05 03:51:22 EDT; 15s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 23785 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 23812 (mysqld)
Status: "Server is operational"
Tasks: 37 (limit: 43552)
Memory: 391.3M
CPU: 2.104s
CGroup: /system.slice/mysqld.service
└─23812 /usr/sbin/mysqld Jul 05 03:51:18 dz systemd[1]: Starting MySQL Server...
Jul 05 03:51:22 dz systemd[1]: Started MySQL Server. #输入mysql唤醒mysql程序
mysql
mysql> # 输入mysql进入“mysql>”提示符表示安装成功,并已经唤醒进入到mysql,首次应该执行下一条命令来修改root管理密码, ALTER USER 'root'@'localhost' identified by '你的新密码';
Enter password: #这里要求的密码要输入上面查出来的临时密码 mysql
# 如果出现 类似“
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
”或“ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
”的情况,可以回退到命令行超级权限,先修改my.cnf,在[mysqld]下面一行添加:
skip-grant-tables
# ESC保存":wq",然后修改密码
mysql -u root -p
mysql
ALTER USER 'root'@'localhost' identified by '你的新密码'; # 出现以下提示说明密码已经修改成功,多登入几次试试能成功进入mysql>并执行相关数据库操作命令,以避免自己埋坑
[root@dz Downloads]# 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.29 MySQL Community Server - GPL 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. # ====================================== [root@dz Downloads]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 8.0.29 MySQL Community Server - GPL 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. # 安装完并已经修改完mysql密码以后,最好是把mysqld服务重启一下,以下为centOS9 Stream操作命令,centOS8类似,其他版本系统自己查命令
systemctl stop mysqld
systemctl start mysqld
systemctl status mysqld
mysql
mysql>

===========================MySQL 8.0.34卸载删除操作======================

测试平台:Oracle Linux 8

说明:如果需要彻底卸载或者遇到问题需要重装,比如更换其他版本等,我们需要彻底卸载删除mysql相关的文件。

# MySQL 8.0.34 卸载删除 (Oracle Linux 8)

systemctl status mysqld
systemctl stop mysqld
systemctl status mysqld rpm -qa | grep mysql rpm -e mysql-community-server-8.0.34-1.el8.x86_64 --nodeps
rpm -e mysql-community-server-debug-8.0.34-1.el8.x86_64 --nodeps
rpm -e mysql-community-debugsource-8.0.34-1.el8.x86_64 --nodeps
rpm -e mysql-community-server-debug-debuginfo-8.0.34-1.el8.x86_64 --nodeps
rpm -e mysql-community-common-8.0.34-1.el8.x86_64 --nodeps
rpm -e mysql-community-icu-data-files-8.0.34-1.el8.x86_64 --nodeps
rpm -e mysql-community-client-8.0.34-1.el8.x86_64 --nodeps
rpm -e mysql-community-test-debuginfo-8.0.34-1.el8.x86_64 --nodeps
rpm -e mysql-community-libs-8.0.34-1.el8.x86_64 --nodeps
rpm -e mysql-community-server-debuginfo-8.0.34-1.el8.x86_64 --nodeps
rpm -e mysql-community-client-debuginfo-8.0.34-1.el8.x86_64 --nodeps
rpm -e mysql-community-libs-debuginfo-8.0.34-1.el8.x86_64 --nodeps
rpm -e mysql-community-debuginfo-8.0.34-1.el8.x86_64 --nodeps
rpm -e mysql-community-devel-8.0.34-1.el8.x86_64 --nodeps
rpm -e mysql-community-client-plugins-debuginfo-8.0.34-1.el8.x86_64 --nodeps
rpm -e mysql-community-client-plugins-8.0.34-1.el8.x86_64 --nodeps rm -rf /var/lib/mysql
rm -rf /var/lib/mysql/mysql.sock
rm -rf /var/run/mysqld/mysqld.pid
rm -rf /var/log/mysqld.log
rm -rf /usr/lib/systemd/system/mysqld.service
rm -rf /usr/lib64/mysql
rm -rf /etc/my.cnf
rm -rf /etc/my.cnf.d

其他版本操作请修改版本号,具体问题具体分析,或直接参考其他教程文章。

centos8 \CentOS 9 Stream \Oracle Linux8\Oracle Linux 9 rpm 安装mysql8.0.28 mysql8.0.34的更多相关文章

  1. Oracle 11gR2_database在Linux下的安装

    Oracle 11gR2_database在Linux下的安装 by:授客 QQ:1033553122 由于篇幅问题,采用链接分享的形式,烦请复制以下网址,黏贴到浏览器中打开,下载 http://pa ...

  2. linux中rpm安装

    目录 一:linux中rpm安装 1.rpm简介 2.区别 3.RPM命令五种基本模式 二:RPM安装全面解析 1,下载软件包 2, 安装软件包 3, 尝试卸载 4, 更新(升级) 5,软件包名称: ...

  3. linux 环境RPM 安装MYSQL5.6

    linux 环境RPM 安装MYSQL5.6 系统环境 CentOS7.2 1.关闭selinux 服务[SELinux是一种基于域-类型 模型(domain-type)的强制访问控制(MAC)安全系 ...

  4. 64位linux下rpm安装mysql的5.5.55版本

    昨天同事开了个阿里云环境,让我帮他安装mysql数据库,本想着很简单的一件事,结果还是折腾了一番.坑很多,一路趟过,一个接一个,只能硬着头皮冲. 首先是下载压缩包,因为采用了rpm安装方式,所以下载的 ...

  5. Linux环境——MySQL安装及配置(8.0版本)

    虚拟机环境是Linux  Red Hat Enterprlse Linux (64位),本次安装的是Mysql 8.0版本. 由于有经验了,所以又弄了台虚拟机练手,承接上一篇博客(https://ww ...

  6. 在Linux上rpm安装运行Redis 3.0.4

    http://www.rpmfind.net搜索redis,找到redis3.0.4的rpm源选做 wget ftp://fr2.rpmfind.net/linux/remi/enterprise/6 ...

  7. 在Linux下的安装mysql-5.7.28 心得总结

    mysql-5.7.28 在Linux下的安装教程图解 这篇文章主要介绍了mysql-5.7.28 的Linux安装,本文通过图文并茂的形式给大家介绍的非常详细,具有一定的参考借鉴价值,希望给有需要的 ...

  8. centos 6.8 搭建禅道 Linux一件安装、进程自起

    禅道官网:http://www.zentao.net/ linux一键安装包内置了apache, php, mysql这些应用程序,只需要下载解压缩即可运行禅道.Linux 64位一键安装包(适用于L ...

  9. Linux系统下安装Angular2开发环境(Ubuntu16.0和deepin)

    说明下,以下过程都是在ubuntu16.0系统下,win系统环境下的安装过程更简单,基本上可以仿效此环境来,除了不用配置系统命令(win下自动可以),node安装是exe程序,一键安装.另外,这里面像 ...

  10. Linux之RPM安装软件

    源码包 (可以看到源代码)      脚本安装包(写好的xsheel一键安装.本质还是源码包和二进制包) 二进制包(RPM包.系统默认包)      包管理系统简单,通过命令就可以安装.卸载     ...

随机推荐

  1. 可视化学习:使用WebGL实现网格背景

    前言 作为前端开发人员,我们最关注的就是应用的交互体验,而元素背景是最基础的交互体验之一.一般而言,能够使用代码实现的界面,我们都会尽可能减少图片的使用,这主要是有几方面的原因,第一,是图片会消耗更多 ...

  2. Jmeter 之 forEach控制器

    1 添加方法: 线程组右键-> 添加 -> 逻辑控制器 ->ForEach控制器   2 作用: 可以更方便JMeter后置处理器提取出来的多组数据,也可以定义具有特定规则的数据,用 ...

  3. Java 常用类 String的常用方法(1)

    1 package com.bytezero.stringclass; 2 3 import org.junit.Test; 4 5 import java.sql.SQLOutput; 6 impo ...

  4. Java //使用scanner从键盘输入多种类型

    1 //1.引入包名 import java.util.Scanner 2 //2.新建Scanner对象 3 Scanner scan = new Scanner(system.in); 4 //3 ...

  5. centos 8远程分发复制jdk到另一个虚拟机

    在localzly节点操作成功后可以使用远程复制命令将JDK远程复制到slave1节点之中:(此命令在localzly中操作) scp -r /usr/java root@slave1:/usr/ 配 ...

  6. js收藏网页功能,纠正网上乱转没求证的案例

    网站一般流行以下收藏代码 function AddFavorite(title, url){ try{ //ie收藏 window.external.addFavorite(url, title); ...

  7. ImageClipboard js粘贴剪切板图片,已测试,可用,可获得base64

    ImageClipboard js粘贴剪切板图片,已测试,可用,可获得base64 具体用到自己项目的时候,拿源码改成自己的库,从写一遍 3个小问题 onpaste 执行了两遍,一次是图片加载完成,一 ...

  8. etcd每个节点都存储了完整的键值对数据集,为什么扩容etcd集群仍可分散存储压力?

    etcd每个节点都存储了完整的键值对数据集,这主要是为了确保数据的一致性和高可用性.在这种设计下,任何一个节点都可以处理读取请求,并在本地提供数据,从而无需跨节点通信.这种冗余的数据存储方式也增加了系 ...

  9. 完美解决浏览器输入http被自动跳转至https问题

    查阅相关资料,发现这是浏览器的HSTS(HTTP Strict Transport Security)功能引起的.在安装配置SSL证书时,可以使用一种能使数据传输更加安全的Web安全协议,即在服务器端 ...

  10. .NET开源快速、强大、免费的电子表格组件

    前言 今天大姚给大家分享一个.NET开源(MIT License).快速.强大.免费的电子表格组件,支持数据格式.冻结.大纲.公式计算.图表.脚本执行等.兼容 Excel 2007 (.xlsx) 格 ...