腾讯云服务器安装mysql

[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)
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 218,640评论 6 507
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 93,254评论 3 395
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 165,011评论 0 355
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,755评论 1 294
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,774评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,610评论 1 305
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,352评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,257评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,717评论 1 315
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,894评论 3 336
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 40,021评论 1 350
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,735评论 5 346
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,354评论 3 330
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,936评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,054评论 1 270
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,224评论 3 371
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,974评论 2 355