• MySql 8.0.22RPM安装


    下载安装包mysql-8.0.22-1.el7.x86_64.rpm-bundle.tar。

    解压安装包

    tar -xf mysql-8.0.22-1.el7.x86_64.rpm-bundle.tar

    [root@mysql1 mysql8]# ll
    total 1719448
    -rwxr-xr-x 1 root root 880353280 Dec 23 14:06 mysql-8.0.22-1.el7.x86_64.rpm-bundle.tar
    -rw-r--r-- 1 7155 31415 49820920 Sep 25 16:58 mysql-community-client-8.0.22-1.el7.x86_64.rpm
    -rw-r--r-- 1 7155 31415 240972 Sep 25 16:59 mysql-community-client-plugins-8.0.22-1.el7.x86_64.rpm
    -rw-r--r-- 1 7155 31415 630772 Sep 25 16:59 mysql-community-common-8.0.22-1.el7.x86_64.rpm
    -rw-r--r-- 1 7155 31415 8468592 Sep 25 16:59 mysql-community-devel-8.0.22-1.el7.x86_64.rpm
    -rw-r--r-- 1 7155 31415 23597312 Sep 25 16:59 mysql-community-embedded-compat-8.0.22-1.el7.x86_64.rpm
    -rw-r--r-- 1 7155 31415 4809544 Sep 25 16:59 mysql-community-libs-8.0.22-1.el7.x86_64.rpm
    -rw-r--r-- 1 7155 31415 1273480 Sep 25 16:59 mysql-community-libs-compat-8.0.22-1.el7.x86_64.rpm
    -rw-r--r-- 1 7155 31415 534432648 Sep 25 17:01 mysql-community-server-8.0.22-1.el7.x86_64.rpm
    -rw-r--r-- 1 7155 31415 257069560 Sep 25 17:03 mysql-community-test-8.0.22-1.el7.x86_64.rpm

    mysql8.0文档中的安装说明

    In most cases, you need to install the mysql-community-server, mysql-community-client,
    mysql-community-libs, mysql-community-common, and mysql-community-libs-compat
    packages to get a functional, standard MySQL installation. To perform such a standard, basic
    installation, go to the folder that contains all those packages (and, preferably, no other RPM packages
    with similar names), and issue the following command:
    shell>sudo yum install mysql-community-{server,client,common,libs}-*

    执行安装 命令

    [root@mysql1 mysql8]# yum install mysql-community-{server,client,common,libs}-*
    Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
    This system is not registered with an entitlement server. You can use subscription-manager to register.
    Examining mysql-community-server-8.0.22-1.el7.x86_64.rpm: mysql-community-server-8.0.22-1.el7.x86_64
    Marking mysql-community-server-8.0.22-1.el7.x86_64.rpm to be installed
    Examining mysql-community-client-8.0.22-1.el7.x86_64.rpm: mysql-community-client-8.0.22-1.el7.x86_64
    Marking mysql-community-client-8.0.22-1.el7.x86_64.rpm to be installed
    Examining mysql-community-client-plugins-8.0.22-1.el7.x86_64.rpm: mysql-community-client-plugins-8.0.22-1.el7.x86_64
    Marking mysql-community-client-plugins-8.0.22-1.el7.x86_64.rpm to be installed
    Examining mysql-community-common-8.0.22-1.el7.x86_64.rpm: mysql-community-common-8.0.22-1.el7.x86_64
    Marking mysql-community-common-8.0.22-1.el7.x86_64.rpm to be installed
    Examining mysql-community-libs-8.0.22-1.el7.x86_64.rpm: mysql-community-libs-8.0.22-1.el7.x86_64
    Marking mysql-community-libs-8.0.22-1.el7.x86_64.rpm to be installed
    Examining mysql-community-libs-compat-8.0.22-1.el7.x86_64.rpm: mysql-community-libs-compat-8.0.22-1.el7.x86_64
    Marking mysql-community-libs-compat-8.0.22-1.el7.x86_64.rpm to be installed
    Resolving Dependencies
    --> Running transaction check
    ---> Package mariadb-libs.x86_64 1:5.5.65-1.el7 will be obsoleted
    ---> Package mysql-community-client.x86_64 0:8.0.22-1.el7 will be installed
    ---> Package mysql-community-client-plugins.x86_64 0:8.0.22-1.el7 will be installed
    ---> Package mysql-community-common.x86_64 0:8.0.22-1.el7 will be installed
    ---> Package mysql-community-libs.x86_64 0:8.0.22-1.el7 will be obsoleting
    ---> Package mysql-community-libs-compat.x86_64 0:8.0.22-1.el7 will be obsoleting
    ---> Package mysql-community-server.x86_64 0:8.0.22-1.el7 will be installed
    --> Finished Dependency Resolution
    base | 3.6 kB 00:00:00
    base/primary_db | 6.1 MB 00:00:00
    epel | 4.7 kB 00:00:00
    epel/updateinfo | 1.0 MB 00:00:00
    epel/primary_db | 6.9 MB 00:00:00
    mirrors.163.com.repo | 3.6 kB 00:00:00
    mirrors.163.com.repo/primary_db | 6.1 MB 00:00:00
    zabbix | 2.9 kB 00:00:00

    Dependencies Resolved

    ====================================================================================================================================================================
    Package Arch Version Repository Size
    ====================================================================================================================================================================
    Installing:
    mysql-community-client x86_64 8.0.22-1.el7 /mysql-community-client-8.0.22-1.el7.x86_64 230 M
    mysql-community-client-plugins x86_64 8.0.22-1.el7 /mysql-community-client-plugins-8.0.22-1.el7.x86_64 1.0 M
    mysql-community-common x86_64 8.0.22-1.el7 /mysql-community-common-8.0.22-1.el7.x86_64 8.9 M
    mysql-community-libs x86_64 8.0.22-1.el7 /mysql-community-libs-8.0.22-1.el7.x86_64 22 M
    replacing mariadb-libs.x86_64 1:5.5.65-1.el7
    mysql-community-libs-compat x86_64 8.0.22-1.el7 /mysql-community-libs-compat-8.0.22-1.el7.x86_64 6.1 M
    replacing mariadb-libs.x86_64 1:5.5.65-1.el7
    mysql-community-server x86_64 8.0.22-1.el7 /mysql-community-server-8.0.22-1.el7.x86_64 2.3 G

    Transaction Summary
    ====================================================================================================================================================================
    Install 6 Packages

    Total size: 2.6 G
    Is this ok [y/d/N]: y
    Downloading packages:
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
    Installing : mysql-community-common-8.0.22-1.el7.x86_64 1/7
    Installing : mysql-community-client-plugins-8.0.22-1.el7.x86_64 2/7
    Installing : mysql-community-libs-8.0.22-1.el7.x86_64 3/7
    Installing : mysql-community-client-8.0.22-1.el7.x86_64 4/7
    Installing : mysql-community-server-8.0.22-1.el7.x86_64 5/7
    Installing : mysql-community-libs-compat-8.0.22-1.el7.x86_64 6/7
    Erasing : 1:mariadb-libs-5.5.65-1.el7.x86_64 7/7
    warning: file /usr/share/mysql/ukrainian/errmsg.sys: remove failed: No such file or directory
    warning: file /usr/share/mysql/ukrainian: remove failed: No such file or directory
    warning: file /usr/share/mysql/swedish/errmsg.sys: remove failed: No such file or directory
    warning: file /usr/share/mysql/swedish: remove failed: No such file or directory
    warning: file /usr/share/mysql/spanish/errmsg.sys: remove failed: No such file or directory
    warning: file /usr/share/mysql/spanish: remove failed: No such file or directory
    warning: file /usr/share/mysql/slovak/errmsg.sys: remove failed: No such file or directory
    warning: file /usr/share/mysql/slovak: remove failed: No such file or directory
    warning: file /usr/share/mysql/serbian/errmsg.sys: remove failed: No such file or directory
    warning: file /usr/share/mysql/serbian: remove failed: No such file or directory
    warning: file /usr/share/mysql/russian/errmsg.sys: remove failed: No such file or directory
    warning: file /usr/share/mysql/russian: remove failed: No such file or directory
    warning: file /usr/share/mysql/romanian/errmsg.sys: remove failed: No such file or directory
    warning: file /usr/share/mysql/romanian: remove failed: No such file or directory
    warning: file /usr/share/mysql/portuguese/errmsg.sys: remove failed: No such file or directory
    warning: file /usr/share/mysql/portuguese: remove failed: No such file or directory
    warning: file /usr/share/mysql/polish/errmsg.sys: remove failed: No such file or directory
    warning: file /usr/share/mysql/polish: remove failed: No such file or directory
    warning: file /usr/share/mysql/norwegian/errmsg.sys: remove failed: No such file or directory
    warning: file /usr/share/mysql/norwegian-ny/errmsg.sys: remove failed: No such file or directory
    warning: file /usr/share/mysql/norwegian-ny: remove failed: No such file or directory
    warning: file /usr/share/mysql/norwegian: remove failed: No such file or directory
    warning: file /usr/share/mysql/korean/errmsg.sys: remove failed: No such file or directory
    warning: file /usr/share/mysql/korean: remove failed: No such file or directory
    warning: file /usr/share/mysql/japanese/errmsg.sys: remove failed: No such file or directory
    warning: file /usr/share/mysql/japanese: remove failed: No such file or directory
    warning: file /usr/share/mysql/italian/errmsg.sys: remove failed: No such file or directory
    warning: file /usr/share/mysql/italian: remove failed: No such file or directory
    warning: file /usr/share/mysql/hungarian/errmsg.sys: remove failed: No such file or directory
    warning: file /usr/share/mysql/hungarian: remove failed: No such file or directory
    warning: file /usr/share/mysql/greek/errmsg.sys: remove failed: No such file or directory
    warning: file /usr/share/mysql/greek: remove failed: No such file or directory
    warning: file /usr/share/mysql/german/errmsg.sys: remove failed: No such file or directory
    warning: file /usr/share/mysql/german: remove failed: No such file or directory
    warning: file /usr/share/mysql/french/errmsg.sys: remove failed: No such file or directory
    warning: file /usr/share/mysql/french: remove failed: No such file or directory
    warning: file /usr/share/mysql/estonian/errmsg.sys: remove failed: No such file or directory
    warning: file /usr/share/mysql/estonian: remove failed: No such file or directory
    warning: file /usr/share/mysql/english/errmsg.sys: remove failed: No such file or directory
    warning: file /usr/share/mysql/english: remove failed: No such file or directory
    warning: file /usr/share/mysql/dutch/errmsg.sys: remove failed: No such file or directory
    warning: file /usr/share/mysql/dutch: remove failed: No such file or directory
    warning: file /usr/share/mysql/danish/errmsg.sys: remove failed: No such file or directory
    warning: file /usr/share/mysql/danish: remove failed: No such file or directory
    warning: file /usr/share/mysql/czech/errmsg.sys: remove failed: No such file or directory
    warning: file /usr/share/mysql/czech: remove failed: No such file or directory
    warning: file /usr/share/mysql/charsets/swe7.xml: remove failed: No such file or directory
    warning: file /usr/share/mysql/charsets/macroman.xml: remove failed: No such file or directory
    warning: file /usr/share/mysql/charsets/macce.xml: remove failed: No such file or directory
    warning: file /usr/share/mysql/charsets/latin7.xml: remove failed: No such file or directory
    warning: file /usr/share/mysql/charsets/latin5.xml: remove failed: No such file or directory
    warning: file /usr/share/mysql/charsets/latin2.xml: remove failed: No such file or directory
    warning: file /usr/share/mysql/charsets/latin1.xml: remove failed: No such file or directory
    warning: file /usr/share/mysql/charsets/koi8u.xml: remove failed: No such file or directory
    warning: file /usr/share/mysql/charsets/koi8r.xml: remove failed: No such file or directory
    warning: file /usr/share/mysql/charsets/keybcs2.xml: remove failed: No such file or directory
    warning: file /usr/share/mysql/charsets/hp8.xml: remove failed: No such file or directory
    warning: file /usr/share/mysql/charsets/hebrew.xml: remove failed: No such file or directory
    warning: file /usr/share/mysql/charsets/greek.xml: remove failed: No such file or directory
    warning: file /usr/share/mysql/charsets/geostd8.xml: remove failed: No such file or directory
    warning: file /usr/share/mysql/charsets/dec8.xml: remove failed: No such file or directory
    warning: file /usr/share/mysql/charsets/cp866.xml: remove failed: No such file or directory
    warning: file /usr/share/mysql/charsets/cp852.xml: remove failed: No such file or directory
    warning: file /usr/share/mysql/charsets/cp850.xml: remove failed: No such file or directory
    warning: file /usr/share/mysql/charsets/cp1257.xml: remove failed: No such file or directory
    warning: file /usr/share/mysql/charsets/cp1256.xml: remove failed: No such file or directory
    warning: file /usr/share/mysql/charsets/cp1251.xml: remove failed: No such file or directory
    warning: file /usr/share/mysql/charsets/cp1250.xml: remove failed: No such file or directory
    warning: file /usr/share/mysql/charsets/ascii.xml: remove failed: No such file or directory
    warning: file /usr/share/mysql/charsets/armscii8.xml: remove failed: No such file or directory
    warning: file /usr/share/mysql/charsets/README: remove failed: No such file or directory
    warning: file /usr/share/mysql/charsets/Index.xml: remove failed: No such file or directory
    warning: file /usr/share/mysql/charsets: remove failed: No such file or directory
    warning: file /usr/share/mysql: remove failed: No such file or directory
    warning: file /usr/lib64/mysql/plugin/mysql_clear_password.so: remove failed: No such file or directory
    warning: file /usr/lib64/mysql/plugin/dialog.so: remove failed: No such file or directory
    warning: file /usr/lib64/mysql/libmysqlclient.so.18.0.0: remove failed: No such file or directory
    Verifying : mysql-community-libs-8.0.22-1.el7.x86_64 1/7
    Verifying : mysql-community-server-8.0.22-1.el7.x86_64 2/7
    Verifying : mysql-community-client-plugins-8.0.22-1.el7.x86_64 3/7
    Verifying : mysql-community-common-8.0.22-1.el7.x86_64 4/7
    Verifying : mysql-community-client-8.0.22-1.el7.x86_64 5/7
    Verifying : mysql-community-libs-compat-8.0.22-1.el7.x86_64 6/7
    Verifying : 1:mariadb-libs-5.5.65-1.el7.x86_64 7/7

    Installed:
    mysql-community-client.x86_64 0:8.0.22-1.el7 mysql-community-client-plugins.x86_64 0:8.0.22-1.el7 mysql-community-common.x86_64 0:8.0.22-1.el7
    mysql-community-libs.x86_64 0:8.0.22-1.el7 mysql-community-libs-compat.x86_64 0:8.0.22-1.el7 mysql-community-server.x86_64 0:8.0.22-1.el7

    Replaced:
    mariadb-libs.x86_64 1:5.5.65-1.el7

    Complete!

    [root@mysql1 mysql8]# systemctl start mysqld
    Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

    [root@mysqlstu1 ~]# tail -111f /var/log/mysqld.log
    2020-12-23T07:13:38.250014Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.22) initializing of server in progress as process 1817
    2020-12-23T07:13:38.250064Z 0 [ERROR] [MY-010338] [Server] Can't find error-message file '/usr/local/mysql/share/mysql-8.0/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.

    rpm安装不能在my.cnf文件中指定basedir,以下是更改后的my.cnf。

    [mysql]
    port = 3306
    socket = /tmp/mysql.sock
    #default-character-set = utf8
    prompt = [\u@\d]\R:\m:\s>

    [client]
    #default-character-set = utf8
    socket = /tmp/mysql.sock

    [mysqld]
    default-authentication-plugin=mysql_native_password
    user=mysql
    #basedir=/usr/local/mysql
    datadir=/opt/mydata/data
    log-error=/var/log/mysqld.log
    socket=/tmp/mysql.sock
    #character-set-server= utf8
    slow_query_log_file = /opt/mydata/logs/slow.log
    log_bin=/opt/mydata/logs/mysql_log_bin
    server_id=97
    slow_query_log=1
    long_query_time=5
    log_queries_not_using_indexes=1
    innodb_undo_directory=/opt/mydata/undo
    innodb_log_files_in_group=3
    log_timestamps=SYSTEM

    pid-file=/var/run/mysqld/mysqld.pid

    #gtid_mode=on
    #enforce_gtid_consistency=on
    #rpl_semi_sync_master_enabled=on
    #rpl_semi_sync_master_wait_for_slave_count=1

    #master_info_repository = TABLE
    #relay_log_info_repository = TABLE
    #binlog_checksum = NONE

    再次启动成功

    [root@mysql1 mysql8]# systemctl start mysqld

    [root@mysql1 mysql8]# systemctl status mysqld
    ● mysqld.service - MySQL Server
    Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
    Active: active (running) since Wed 2020-12-23 15:45:23 CST; 27min ago
    Docs: man:mysqld(8)
    http://dev.mysql.com/doc/refman/en/using-systemd.html
    Process: 2535 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
    Main PID: 2607 (mysqld)
    Status: "Server is operational"
    CGroup: /system.slice/mysqld.service
    └─2607 /usr/sbin/mysqld

    Dec 23 15:45:17 mysqlstu1 systemd[1]: Starting MySQL Server...
    Dec 23 15:45:23 mysqlstu1 systemd[1]: Started MySQL Server.

    找到root初始密码

    [root@mysql1 mydata]# grep 'temporary password' /var/log/mysqld.log
    2020-12-23T07:45:19.940049Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 2,h942i#gtuR

    [root@mysql1 mysql8]# mysql -uroot -A -p2,h942i#gtuR
    mysql: [Warning] Using a password on the command line interface can be insecure.
    Welcome to the MySQL monitor. Commands end with ; or g.
    Your MySQL connection id is 8
    Server version: 8.0.22

    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.

    [root@(none)]16:13:25>g
    ERROR:
    No query specified

    [root@(none)]16:13:41>c
    [root@(none)]16:13:58>show databases;
    ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

    登录后必须要先更新密码

    [root@(none)]16:16:32>ALTER USER 'root'@'localhost' IDENTIFIED BY 'Abcd!@34';
    Query OK, 0 rows affected (0.00 sec)

    密码策略改简单点

    [root@sys]16:19:56>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 |
    +--------------------------------------+--------+

    [root@sys]16:26:24>set global validate_password.policy=0;
    Query OK, 0 rows affected (0.00 sec)

    更改root用户远程登录
    [root@sys]16:32:47>update mysql.user set host = '%' where user = 'root';
    Query OK, 1 row affected (0.00 sec)
    Rows matched: 1 Changed: 1 Warnings: 0

    [root@sys]16:33:26>select User,authentication_string,Host from mysql.user;
    +------------------+------------------------------------------------------------------------+-----------+
    | User | authentication_string | Host |
    +------------------+------------------------------------------------------------------------+-----------+
    | root | *281E87151EDAF9135605BA99E36B54FBB222A2C7 | % |
    | mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | localhost |
    | mysql.session | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | localhost |
    | mysql.sys | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | localhost |
    +------------------+------------------------------------------------------------------------+-----------+
    4 rows in set (0.00 sec)

    [root@sys]16:33:29>set global validate_password.length=4;
    Query OK, 0 rows affected (0.00 sec)

    [root@sys]16:36:39>flush privileges;
    Query OK, 0 rows affected (0.00 sec)

    [root@sys]16:37:05>ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'abcd' ;
    Query OK, 0 rows affected (0.00 sec)

    这样就可以远程连接到mysql数据库了。密码策略更改只是临时有效,需要在my.cnf中添加才永久生效。

    rpm安装将mysql安装到了/usr/share目录中

    [root@mysqlstu1 bin]# ls /usr/share/mysql-8.0
    bulgarian dictionary.txt french innodb_memcached_config.sql korean norwegian romanian spanish
    charsets dutch german install_rewriter.sql messages_to_clients.txt norwegian-ny russian swedish
    czech english greek italian messages_to_error_log.txt polish serbian ukrainian
    danish estonian hungarian japanese mysql-log-rotate portuguese slovak uninstall_rewriter.sql

    小结一下:
    1、rpm安装时不要指定basedir;

    2、初始化mysql时如果出现错误,再次执行前要删除datadir中的所有文件;

    3、查看mysql错误日志时发现时间与系统时间不一致,相差8个小时,mysql有一个全局变量log_timestamps默认为UTC,

    可以通过set global log_timestamps=SYSTEM;临时设置为与系统一致,当系统重启后,配置就失效,需要添加到my.cnf中。

  • 相关阅读:
    合并字符串中的多个空格
    IfcSpecularRoughness
    IfcSpecularExponent
    IfcPresentableText
    IfcFontWeight
    IfcFontVariant
    uwb ifc模型定位測試
    IfcFontStyle
    IfcGeometricModelResource
    qt6安装
  • 原文地址:https://www.cnblogs.com/historynote/p/14179498.html
Copyright © 2020-2023  润新知