• 阿里云服务器centos7.6安装mysql8.0.23


    https://dev.mysql.com/doc/refman/8.0/en/linux-installation-yum-repo.html#yum-repo-installing-mysql

    修改主机名:

    [root@iZbp14u808b24i4zml939uZ /]# hostnamectl set -hostname vmcentos7.aliyun

    安装新版mysql,现为8.0.23

    [root@iZbp14u808b24i4zml939uZ /]# wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
    --2021-01-18 12:01:38-- https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
    Resolving dev.mysql.com (dev.mysql.com)... 137.254.60.11
    Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:443... connected.
    HTTP request sent, awaiting response... 302 Found
    Location: https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm [following]
    --2021-01-18 12:01:40-- https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm
    Resolving repo.mysql.com (repo.mysql.com)... 23.40.193.17
    Connecting to repo.mysql.com (repo.mysql.com)|23.40.193.17|:443... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 26024 (25K) [application/x-redhat-package-manager]
    Saving to: ‘mysql80-community-release-el7-3.noarch.rpm’

    100%[===================================================================================================================================================================================================>] 26,024 165KB/s in 0.2s

    2021-01-18 12:01:40 (165 KB/s) - ‘mysql80-community-release-el7-3.noarch.rpm’ saved [26024/26024]

    [root@iZbp14u808b24i4zml939uZ /]# yum -y install mysql80-community-release-el7-3.noarch.rpm
    Loaded plugins: fastestmirror
    Examining mysql80-community-release-el7-3.noarch.rpm: mysql80-community-release-el7-3.noarch
    Marking mysql80-community-release-el7-3.noarch.rpm to be installed
    Resolving Dependencies
    --> Running transaction check
    ---> Package mysql80-community-release.noarch 0:el7-3 will be installed
    --> Finished Dependency Resolution

    Dependencies Resolved

    =============================================================================================================================================================================================================================================
    Package Arch Version Repository Size
    =============================================================================================================================================================================================================================================
    Installing:
    mysql80-community-release noarch el7-3 /mysql80-community-release-el7-3.noarch 31 k

    Transaction Summary
    =============================================================================================================================================================================================================================================
    Install 1 Package

    Total size: 31 k
    Installed size: 31 k
    Downloading packages:
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
    Installing : mysql80-community-release-el7-3.noarch 1/1
    Verifying : mysql80-community-release-el7-3.noarch 1/1

    Installed:
    mysql80-community-release.noarch 0:el7-3

    Complete!
    [root@iZbp14u808b24i4zml939uZ /]# yum install mysql-community-server
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    mysql-connectors-community | 2.6 kB 00:00:00
    mysql-tools-community | 2.6 kB 00:00:00
    mysql80-community | 2.6 kB 00:00:00
    (1/3): mysql-connectors-community/x86_64/primary_db | 72 kB 00:00:00
    (2/3): mysql-tools-community/x86_64/primary_db | 85 kB 00:00:00
    (3/3): mysql80-community/x86_64/primary_db | 142 kB 00:00:01
    Resolving Dependencies
    --> Running transaction check
    ---> Package mysql-community-server.x86_64 0:8.0.23-1.el7 will be installed
    --> Processing Dependency: mysql-community-common(x86-64) = 8.0.23-1.el7 for package: mysql-community-server-8.0.23-1.el7.x86_64
    --> Processing Dependency: mysql-community-client(x86-64) >= 8.0.11 for package: mysql-community-server-8.0.23-1.el7.x86_64
    --> Processing Dependency: libaio.so.1(LIBAIO_0.1)(64bit) for package: mysql-community-server-8.0.23-1.el7.x86_64
    --> Processing Dependency: libaio.so.1(LIBAIO_0.4)(64bit) for package: mysql-community-server-8.0.23-1.el7.x86_64
    --> Processing Dependency: libaio.so.1()(64bit) for package: mysql-community-server-8.0.23-1.el7.x86_64
    --> Running transaction check
    ---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
    ---> Package mysql-community-client.x86_64 0:8.0.23-1.el7 will be installed
    --> Processing Dependency: mysql-community-client-plugins = 8.0.23-1.el7 for package: mysql-community-client-8.0.23-1.el7.x86_64
    --> Processing Dependency: mysql-community-libs(x86-64) >= 8.0.11 for package: mysql-community-client-8.0.23-1.el7.x86_64
    ---> Package mysql-community-common.x86_64 0:8.0.23-1.el7 will be installed
    --> Running transaction check
    ---> Package mariadb-libs.x86_64 1:5.5.68-1.el7 will be obsoleted
    --> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-9.el7.x86_64
    --> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-9.el7.x86_64
    ---> Package mysql-community-client-plugins.x86_64 0:8.0.23-1.el7 will be installed
    ---> Package mysql-community-libs.x86_64 0:8.0.23-1.el7 will be obsoleting
    --> Running transaction check
    ---> Package mysql-community-libs-compat.x86_64 0:8.0.23-1.el7 will be obsoleting
    --> Finished Dependency Resolution

    Dependencies Resolved

    =============================================================================================================================================================================================================================================
    Package Arch Version Repository Size
    =============================================================================================================================================================================================================================================
    Installing:
    mysql-community-libs x86_64 8.0.23-1.el7 mysql80-community 4.6 M
    replacing mariadb-libs.x86_64 1:5.5.68-1.el7
    mysql-community-libs-compat x86_64 8.0.23-1.el7 mysql80-community 1.2 M
    replacing mariadb-libs.x86_64 1:5.5.68-1.el7
    mysql-community-server x86_64 8.0.23-1.el7 mysql80-community 518 M
    Installing for dependencies:
    libaio x86_64 0.3.109-13.el7 base 24 k
    mysql-community-client x86_64 8.0.23-1.el7 mysql80-community 48 M
    mysql-community-client-plugins x86_64 8.0.23-1.el7 mysql80-community 237 k
    mysql-community-common x86_64 8.0.23-1.el7 mysql80-community 621 k

    Transaction Summary
    =============================================================================================================================================================================================================================================
    Install 3 Packages (+4 Dependent packages)

    Total download size: 573 M
    Is this ok [y/d/N]: y
    Downloading packages:
    (1/7): libaio-0.3.109-13.el7.x86_64.rpm | 24 kB 00:00:00
    warning: /var/cache/yum/x86_64/7/mysql80-community/packages/mysql-community-client-plugins-8.0.23-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY ] 139 kB/s | 264 kB 01:10:24 ETA
    Public key for mysql-community-client-plugins-8.0.23-1.el7.x86_64.rpm is not installed
    (2/7): mysql-community-client-plugins-8.0.23-1.el7.x86_64.rpm | 237 kB 00:00:01
    (3/7): mysql-community-common-8.0.23-1.el7.x86_64.rpm | 621 kB 00:00:00
    (4/7): mysql-community-libs-8.0.23-1.el7.x86_64.rpm | 4.6 MB 00:00:01
    (5/7): mysql-community-libs-compat-8.0.23-1.el7.x86_64.rpm | 1.2 MB 00:00:00
    (6/7): mysql-community-client-8.0.23-1.el7.x86_64.rpm | 48 MB 00:00:09
    (7/7): mysql-community-server-8.0.23-1.el7.x86_64.rpm | 518 MB 00:01:48
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Total 5.1 MB/s | 573 MB 00:01:51
    Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
    Importing GPG key 0x5072E1F5:
    Userid : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
    Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
    Package : mysql80-community-release-el7-3.noarch (@/mysql80-community-release-el7-3.noarch)
    From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
    Is this ok [y/N]: y
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
    Installing : mysql-community-common-8.0.23-1.el7.x86_64 1/8
    Installing : mysql-community-client-plugins-8.0.23-1.el7.x86_64 2/8
    Installing : mysql-community-libs-8.0.23-1.el7.x86_64 3/8
    Installing : mysql-community-client-8.0.23-1.el7.x86_64 4/8
    Installing : libaio-0.3.109-13.el7.x86_64 5/8
    Installing : mysql-community-server-8.0.23-1.el7.x86_64 6/8
    Installing : mysql-community-libs-compat-8.0.23-1.el7.x86_64 7/8
    Erasing : 1:mariadb-libs-5.5.68-1.el7.x86_64 8/8
    Verifying : mysql-community-client-8.0.23-1.el7.x86_64 1/8
    Verifying : mysql-community-libs-compat-8.0.23-1.el7.x86_64 2/8
    Verifying : mysql-community-libs-8.0.23-1.el7.x86_64 3/8
    Verifying : mysql-community-client-plugins-8.0.23-1.el7.x86_64 4/8
    Verifying : mysql-community-server-8.0.23-1.el7.x86_64 5/8
    Verifying : libaio-0.3.109-13.el7.x86_64 6/8
    Verifying : mysql-community-common-8.0.23-1.el7.x86_64 7/8
    Verifying : 1:mariadb-libs-5.5.68-1.el7.x86_64 8/8

    Installed:
    mysql-community-libs.x86_64 0:8.0.23-1.el7 mysql-community-libs-compat.x86_64 0:8.0.23-1.el7 mysql-community-server.x86_64 0:8.0.23-1.el7

    Dependency Installed:
    libaio.x86_64 0:0.3.109-13.el7 mysql-community-client.x86_64 0:8.0.23-1.el7 mysql-community-client-plugins.x86_64 0:8.0.23-1.el7 mysql-community-common.x86_64 0:8.0.23-1.el7

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

    Complete!

    [root@iZbp14u808b24i4zml939uZ /]# systemctl start mysqld.service
    [root@iZbp14u808b24i4zml939uZ /]# systemctl enable mysqld.service

    [root@iZbp14u808b24i4zml939uZ /]# systemctl status mysqld.service
    ● mysqld.service - MySQL Server
    Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
    Active: active (running) since Mon 2021-01-18 12:30:20 CST; 59s ago
    Docs: man:mysqld(8)
    http://dev.mysql.com/doc/refman/en/using-systemd.html
    Main PID: 11129 (mysqld)
    Status: "Server is operational"
    CGroup: /system.slice/mysqld.service
    └─11129 /usr/sbin/mysqld

    Jan 18 12:30:10 iZbp14u808b24i4zml939uZ systemd[1]: Starting MySQL Server...
    Jan 18 12:30:20 iZbp14u808b24i4zml939uZ systemd[1]: Started MySQL Server.

    [root@iZbp14u808b24i4zml939uZ /]# vim /var/log/mysqld.log

    2021-01-18T04:30:15.128686Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: A3%?y_SDfGKZ

    [root@iZbp14u808b24i4zml939uZ /]# mysql -u root -p
    Enter password:
    Welcome to the MySQL monitor. Commands end with ; or g.
    Your MySQL connection id is 8
    Server version: 8.0.23

    Copyright (c) 2000, 2021, 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>

    mysql> set global validate_password.policy=0;

    mysql> set global validate_password.length=4;

    mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';

    mysql> exit
    Bye
    [root@iZbp14u808b24i4zml939uZ /]# yum remove mysql80-community-release-el7-3.noarch
    Loaded plugins: fastestmirror
    Resolving Dependencies
    --> Running transaction check
    ---> Package mysql80-community-release.noarch 0:el7-3 will be erased
    --> Finished Dependency Resolution

    Dependencies Resolved

    =======================================================================================================
    Package Arch Version Repository Size
    =======================================================================================================
    Removing:
    mysql80-community-release noarch el7-3 @/mysql80-community-release-el7-3.noarch 31 k

    Transaction Summary
    =======================================================================================================
    Remove 1 Package

    Installed size: 31 k
    Is this ok [y/N]: y
    Downloading packages:
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
    Erasing : mysql80-community-release-el7-3.noarch 1/1
    Verifying : mysql80-community-release-el7-3.noarch 1/1

    Removed:
    mysql80-community-release.noarch 0:el7-3

    Complete!

    [root@iZbp14u808b24i4zml939uZ /]# rm -rf mysql80-community-release-el7-3.noarch.rpm

    在CentOS中mysql的主要配置所在的目录:

    1 /etc/my.cnf 这是mysql的主配置文件
    2 /var/lib/mysql mysql数据库的数据库文件存放位置
    3 /var/log mysql数据库的日志输出存放位置

    $ /usr/local/mysql/bin/mysql -u root -p
    --输入密码
    mysql> show databases;
    +--------------------+
    | Database |
    +--------------------+
    | information_schema |
    | mysql |
    | performance_schema |
    | seckill |
    | sys |
    | test |
    +--------------------+
    6 rows in set (0.00 sec)
    mysql> use mysql;
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A

    Database changed
    --查询当前数据库相关信息
    mysql> select host,user,authentication_string,plugin from user;
    +-----------+------------------+------------------------------------------------------------------------+-----------------------+
    | host | user | authentication_string | plugin |
    +-----------+------------------+------------------------------------------------------------------------+-----------------------+
    | localhost | mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
    | localhost | mysql.session | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
    | localhost | mysql.sys | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
    | localhost | root | *84AAC12F54AB666ECFC2A83C676908C8BBC381B1 | mysql_native_password |
    +-----------+------------------+------------------------------------------------------------------------+-----------------------+
    4 rows in set (0.00 sec)

    --将root用户设置为所有地址可登录,原来是localhost表示只用本机可登录
    mysql> update user set host='%' where user='root';
    Query OK, 1 row affected (0.01 sec)
    Rows matched: 1 Changed: 1 Warnings: 0

    --刷新权限
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)

    --将用户root密码设置为永不过期
    mysql> alter user 'root'@'%' identified by '12345678' password expire never;
    Query OK, 0 rows affected (0.01 sec)

    --将root用户密码加密方式改为mysql_native_password ,上面查到root用户密码的加密方式为caching_sha2_password
    mysql> alter user 'root'@'%' identified with mysql_native_password by '12345678';
    Query OK, 0 rows affected (0.00 sec)

    --刷新权限,在别的机器上即可登录
    mysql> flush privileges;

  • 相关阅读:
    JS可改变列宽table
    无图片,用css border实现尖三角
    IE6下position:fixed;兼容
    巧用cssText属性批量操作样式
    Java
    Java
    Java
    JRebel
    Spring
    ActiveMQ
  • 原文地址:https://www.cnblogs.com/xwhgr/p/14292076.html
Copyright © 2020-2023  润新知