美文网首页
腾讯云服务器安装mysql

腾讯云服务器安装mysql

作者: 诗酒趁年华_d593 | 来源:发表于2020-06-14 10:34 被阅读0次
    [root@VM_0_16_centos ~]# rpm -qa | grep mysql
    [root@VM_0_16_centos ~]# rpm -qa|grep mysql*
    [root@VM_0_16_centos ~]# rpm -qa|grep -i mysql
    [root@VM_0_16_centos ~]# sudo wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
    --2020-06-03 19:54:23--  https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
    Resolving repo.mysql.com (repo.mysql.com)... 23.36.53.20
    Connecting to repo.mysql.com (repo.mysql.com)|23.36.53.20|:443... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 25820 (25K) [application/x-redhat-package-manager]
    Saving to: ‘mysql80-community-release-el7-1.noarch.rpm’
    
    100%[=================================================================>] 25,820      --.-K/s   in 0s      
    
    2020-06-03 19:54:24 (486 MB/s) - ‘mysql80-community-release-el7-1.noarch.rpm’ saved [25820/25820]
    
    [root@VM_0_16_centos ~]# sudo rpm -ivh mysql80-community-release-el7-1.noarch.rpm 
    warning: mysql80-community-release-el7-1.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
    Preparing...                          ################################# [100%]
    Updating / installing...
       1:mysql80-community-release-el7-1  ################################# [100%]
    [root@VM_0_16_centos ~]# sudo yum install mysql-server
    Loaded plugins: fastestmirror, langpacks
    Determining fastest mirrors
    epel                                                                                | 4.7 kB  00:00:00     
    extras                                                                              | 2.9 kB  00:00:00     
    mysql-connectors-community                                                          | 2.5 kB  00:00:00     
    mysql-tools-community                                                               | 2.5 kB  00:00:00     
    mysql80-community                                                                   | 2.5 kB  00:00:00     
    os                                                                                  | 3.6 kB  00:00:00     
    updates                                                                             | 2.9 kB  00:00:00     
    (1/3): mysql-connectors-community/x86_64/primary_db                                 |  57 kB  00:00:01     
    (2/3): mysql80-community/x86_64/primary_db                                          | 107 kB  00:00:03     
    (3/3): mysql-tools-community/x86_64/primary_db                                      |  72 kB  00:00:04     
    Resolving Dependencies
    --> Running transaction check
    ---> Package mysql-community-server.x86_64 0:8.0.20-1.el7 will be installed
    --> Processing Dependency: mysql-community-common(x86-64) = 8.0.20-1.el7 for package: mysql-community-server-8.0.20-1.el7.x86_64
    --> Processing Dependency: mysql-community-client(x86-64) >= 8.0.11 for package: mysql-community-server-8.0.20-1.el7.x86_64
    --> Processing Dependency: libnuma.so.1(libnuma_1.2)(64bit) for package: mysql-community-server-8.0.20-1.el7.x86_64
    --> Processing Dependency: libnuma.so.1(libnuma_1.1)(64bit) for package: mysql-community-server-8.0.20-1.el7.x86_64
    --> Processing Dependency: libnuma.so.1()(64bit) for package: mysql-community-server-8.0.20-1.el7.x86_64
    --> Running transaction check
    ---> Package mysql-community-client.x86_64 0:8.0.20-1.el7 will be installed
    --> Processing Dependency: mysql-community-libs(x86-64) >= 8.0.11 for package: mysql-community-client-8.0.20-1.el7.x86_64
    ---> Package mysql-community-common.x86_64 0:8.0.20-1.el7 will be installed
    ---> Package numactl-libs.x86_64 0:2.0.12-5.el7 will be installed
    --> Running transaction check
    ---> Package mariadb-libs.x86_64 1:5.5.56-2.el7 will be obsoleted
    --> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
    --> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
    ---> Package mysql-community-libs.x86_64 0:8.0.20-1.el7 will be obsoleting
    --> Running transaction check
    ---> Package mysql-community-libs-compat.x86_64 0:8.0.20-1.el7 will be obsoleting
    ---> Package postfix.x86_64 2:2.10.1-6.el7 will be updated
    ---> Package postfix.x86_64 2:2.10.1-9.el7 will be an update
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ===========================================================================================================
     Package                             Arch           Version                Repository                 Size
    ===========================================================================================================
    Installing:
     mysql-community-libs                x86_64         8.0.20-1.el7           mysql80-community         4.5 M
         replacing  mariadb-libs.x86_64 1:5.5.56-2.el7
     mysql-community-libs-compat         x86_64         8.0.20-1.el7           mysql80-community         1.2 M
         replacing  mariadb-libs.x86_64 1:5.5.56-2.el7
     mysql-community-server              x86_64         8.0.20-1.el7           mysql80-community         488 M
    Installing for dependencies:
     mysql-community-client              x86_64         8.0.20-1.el7           mysql80-community          47 M
     mysql-community-common              x86_64         8.0.20-1.el7           mysql80-community         609 k
     numactl-libs                        x86_64         2.0.12-5.el7           os                         30 k
    Updating for dependencies:
     postfix                             x86_64         2:2.10.1-9.el7         os                        2.4 M
    
    Transaction Summary
    ===========================================================================================================
    Install  3 Packages (+3 Dependent packages)
    Upgrade             ( 1 Dependent package)
    
    Total download size: 544 M
    Is this ok [y/d/N]: y
    Downloading packages:
    Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
    warning: /var/cache/yum/x86_64/7/mysql80-community/packages/mysql-community-common-8.0.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
    Public key for mysql-community-common-8.0.20-1.el7.x86_64.rpm is not installed
    (1/7): mysql-community-common-8.0.20-1.el7.x86_64.rpm                               | 609 kB  00:00:06     
    (2/7): mysql-community-libs-8.0.20-1.el7.x86_64.rpm                                 | 4.5 MB  00:00:13     
    (3/7): mysql-community-libs-compat-8.0.20-1.el7.x86_64.rpm                          | 1.2 MB  00:00:04     
    (4/7): numactl-libs-2.0.12-5.el7.x86_64.rpm                                         |  30 kB  00:00:00     
    (5/7): postfix-2.10.1-9.el7.x86_64.rpm                                              | 2.4 MB  00:00:00     
    (6/7): mysql-community-client-8.0.20-1.el7.x86_64.rpm                               |  47 MB  00:01:01     
    (7/7): mysql-community-server-8.0.20-1.el7.x86_64.rpm                               | 488 MB  00:09:03     
    -----------------------------------------------------------------------------------------------------------
    Total                                                                      980 kB/s | 544 MB  00:09:28     
    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-1.noarch (installed)
     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
    Warning: RPMDB altered outside of yum.
      Installing : mysql-community-common-8.0.20-1.el7.x86_64                                              1/9 
      Installing : mysql-community-libs-8.0.20-1.el7.x86_64                                                2/9 
      Installing : mysql-community-libs-compat-8.0.20-1.el7.x86_64                                         3/9 
      Installing : mysql-community-client-8.0.20-1.el7.x86_64                                              4/9 
      Installing : numactl-libs-2.0.12-5.el7.x86_64                                                        5/9 
      Installing : mysql-community-server-8.0.20-1.el7.x86_64                                              6/9 
      Updating   : 2:postfix-2.10.1-9.el7.x86_64                                                           7/9 
      Cleanup    : 2:postfix-2.10.1-6.el7.x86_64                                                           8/9 
      Erasing    : 1:mariadb-libs-5.5.56-2.el7.x86_64                                                      9/9 
      Verifying  : mysql-community-libs-compat-8.0.20-1.el7.x86_64                                         1/9 
      Verifying  : mysql-community-common-8.0.20-1.el7.x86_64                                              2/9 
      Verifying  : 2:postfix-2.10.1-9.el7.x86_64                                                           3/9 
      Verifying  : numactl-libs-2.0.12-5.el7.x86_64                                                        4/9 
      Verifying  : mysql-community-server-8.0.20-1.el7.x86_64                                              5/9 
      Verifying  : mysql-community-client-8.0.20-1.el7.x86_64                                              6/9 
      Verifying  : mysql-community-libs-8.0.20-1.el7.x86_64                                                7/9 
      Verifying  : 1:mariadb-libs-5.5.56-2.el7.x86_64                                                      8/9 
      Verifying  : 2:postfix-2.10.1-6.el7.x86_64                                                           9/9 
    
    Installed:
      mysql-community-libs.x86_64 0:8.0.20-1.el7        mysql-community-libs-compat.x86_64 0:8.0.20-1.el7     
      mysql-community-server.x86_64 0:8.0.20-1.el7     
    
    Dependency Installed:
      mysql-community-client.x86_64 0:8.0.20-1.el7         mysql-community-common.x86_64 0:8.0.20-1.el7        
      numactl-libs.x86_64 0:2.0.12-5.el7                  
    
    Dependency Updated:
      postfix.x86_64 2:2.10.1-9.el7                                                                            
    
    Replaced:
      mariadb-libs.x86_64 1:5.5.56-2.el7                                                                       
    
    Complete!
    [root@VM_0_16_centos ~]# mysql -v
    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
    [root@VM_0_16_centos ~]# mysql -V
    mysql  Ver 8.0.20 for Linux on x86_64 (MySQL Community Server - GPL)
    [root@VM_0_16_centos ~]# service mysqld start
    Redirecting to /bin/systemctl start mysqld.service
    [root@VM_0_16_centos ~]# service mysqld status
    Redirecting to /bin/systemctl status mysqld.service
    ● mysqld.service - MySQL Server
       Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
       Active: active (running) since Wed 2020-06-03 20:16:55 CST; 32s ago
         Docs: man:mysqld(8)
               http://dev.mysql.com/doc/refman/en/using-systemd.html
      Process: 16815 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
     Main PID: 16904 (mysqld)
       Status: "Server is operational"
       CGroup: /system.slice/mysqld.service
               └─16904 /usr/sbin/mysqld
    
    Jun 03 20:16:45 VM_0_16_centos systemd[1]: Starting MySQL Server...
    Jun 03 20:16:55 VM_0_16_centos systemd[1]: Started MySQL Server.
    [root@VM_0_16_centos ~]# grep "password" /var/log/mysqld.log
    2020-06-03T12:16:50.104352Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: y)W<5voG3sKa
    [root@VM_0_16_centos ~]# mysql -u ront -p y)W<5voG3sKa 
    -bash: syntax error near unexpected token `)'
    [root@VM_0_16_centos ~]# mysql -uroot -py)W<5voG3sKa
    -bash: syntax error near unexpected token `)'
    [root@VM_0_16_centos ~]# 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.20
    
    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.
    
    mysql> alter user user() identified by '520vaeWT';
    ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
    mysql> alter user user() identified by '520vae@WT';
    Query OK, 0 rows affected (0.01 sec)
    
    mysql> ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER; 
    Query OK, 0 rows affected (0.01 sec)
    
    mysql> flush privileges; 
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> show database;
    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 'database' at line 1
    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | sys                |
    +--------------------+
    4 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 user,host from user;
    +------------------+-----------+
    | user             | host      |
    +------------------+-----------+
    | mysql.infoschema | localhost |
    | mysql.session    | localhost |
    | mysql.sys        | localhost |
    | root             | localhost |
    +------------------+-----------+
    4 rows in set (0.00 sec)
    
    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.01 sec)
    
    mysql> select user,host from user;
    +------------------+-----------+
    | user             | host      |
    +------------------+-----------+
    | root             | %         |
    | mysql.infoschema | localhost |
    | mysql.session    | localhost |
    | mysql.sys        | localhost |
    +------------------+-----------+
    4 rows in set (0.00 sec)
    
    mysql> 
    
    

    MySQL 连接出现 Authentication plugin 'caching_sha2_password' cannot be loaded

    alter user 'root'@'%' identified with mysql_native_password by '你的mysql登录密码';
    

    创建子用户

    mysql> create user 'vae'@'%' identified with mysql_native_password by '520vae@WT';
    Query OK, 0 rows affected (0.01 sec)
    
    mysql> grant all privileges on *.* to 'vae'@'%' with grant option;
    Query OK, 0 rows affected (0.02 sec)
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    

    相关文章

      网友评论

          本文标题:腾讯云服务器安装mysql

          本文链接:https://www.haomeiwen.com/subject/mvfizhtx.html