MySQL8.0.16 单机 Linux安装以及使用

博客介绍了MySQL8的安装与Navicat连接方法。先从官网下载并上传到Linux,解压安装,开启防火墙端口3306并启动,首次启动需修改密码。连接Navicat时,要创建新用户并授权,若因加密协议问题无法连接,可将加密方式更改为mysql_native_password。

安装

先去下载 https://dev.mysql.com/downloads/mysql/

然后上传到Linux

进入存放目录,解压到指定目录【我这里是/soft/mysql8

[root@localhost ~]# cd /soft/
[root@localhost soft]# mkdir mysql8
[root@localhost soft]# tar -xvf mysql-8.0.16-2.el7.x86_64.rpm-bundle.tar -C mysql8/
mysql-community-libs-8.0.16-2.el7.x86_64.rpm
mysql-community-embedded-compat-8.0.16-2.el7.x86_64.rpm
mysql-community-devel-8.0.16-2.el7.x86_64.rpm
mysql-community-server-8.0.16-2.el7.x86_64.rpm
mysql-community-libs-compat-8.0.16-2.el7.x86_64.rpm
mysql-community-client-8.0.16-2.el7.x86_64.rpm
mysql-community-common-8.0.16-2.el7.x86_64.rpm
mysql-community-test-8.0.16-2.el7.x86_64.rpm

 

进入解压后的目录,安装

[root@localhost soft]# cd mysql8/
[root@localhost mysql8]# yum install mysql-community-{server,client,common,libs}-*
Loaded plugins: fastestmirror, langpacks
Examining mysql-community-server-8.0.16-2.el7.x86_64.rpm: mysql-community-server-8.0.16-2.el7.x86_64
Marking mysql-community-server-8.0.16-2.el7.x86_64.rpm to be installed
Examining mysql-community-client-8.0.16-2.el7.x86_64.rpm: mysql-community-client-8.0.16-2.el7.x86_64
Marking mysql-community-client-8.0.16-2.el7.x86_64.rpm to be installed
Examining mysql-community-common-8.0.16-2.el7.x86_64.rpm: mysql-community-common-8.0.16-2.el7.x86_64
Marking mysql-community-common-8.0.16-2.el7.x86_64.rpm to be installed
Examining mysql-community-libs-8.0.16-2.el7.x86_64.rpm: mysql-community-libs-8.0.16-2.el7.x86_64
Marking mysql-community-libs-8.0.16-2.el7.x86_64.rpm to be installed
Examining mysql-community-libs-compat-8.0.16-2.el7.x86_64.rpm: mysql-community-libs-compat-8.0.16-2.el7.x86_64
Marking mysql-community-libs-compat-8.0.16-2.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.60-1.el7_5 will be obsoleted
---> Package mysql-community-client.x86_64 0:8.0.16-2.el7 will be installed
---> Package mysql-community-common.x86_64 0:8.0.16-2.el7 will be installed
---> Package mysql-community-libs.x86_64 0:8.0.16-2.el7 will be obsoleting
---> Package mysql-community-libs-compat.x86_64 0:8.0.16-2.el7 will be obsoleting
---> Package mysql-community-server.x86_64 0:8.0.16-2.el7 will be installed
--> Finished Dependency Resolution
base/7/x86_64                                                                                                                                                                                                             | 3.6 kB  00:00:00     
extras/7/x86_64                                                                                                                                                                                                           | 3.4 kB  00:00:00     
updates/7/x86_64                                                                                                                                                                                                          | 3.4 kB  00:00:00     

Dependencies Resolved

=================================================================================================================================================================================================================================================
 Package                                                       Arch                                     Version                                         Repository                                                                          Size
=================================================================================================================================================================================================================================================
Installing:
 mysql-community-client                                        x86_64                                   8.0.16-2.el7                                    /mysql-community-client-8.0.16-2.el7.x86_64                                        143 M
 mysql-community-common                                        x86_64                                   8.0.16-2.el7                                    /mysql-community-common-8.0.16-2.el7.x86_64                                        8.0 M
 mysql-community-libs                                          x86_64                                   8.0.16-2.el7                                    /mysql-community-libs-8.0.16-2.el7.x86_64                                           14 M
     replacing  mariadb-libs.x86_64 1:5.5.60-1.el7_5
 mysql-community-libs-compat                                   x86_64                                   8.0.16-2.el7                                    /mysql-community-libs-compat-8.0.16-2.el7.x86_64                                   9.5 M
     replacing  mariadb-libs.x86_64 1:5.5.60-1.el7_5
 mysql-community-server                                        x86_64                                   8.0.16-2.el7                                    /mysql-community-server-8.0.16-2.el7.x86_64                                        1.8 G

Transaction Summary
=================================================================================================================================================================================================================================================
Install  5 Packages

Total size: 1.9 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.16-2.el7.x86_64                                                                                                                                                                                    1/6 
  Installing : mysql-community-libs-8.0.16-2.el7.x86_64                                                                                                                                                                                      2/6 
  Installing : mysql-community-client-8.0.16-2.el7.x86_64                                                                                                                                                                                    3/6 
  Installing : mysql-community-server-8.0.16-2.el7.x86_64                                                                                                                                                                                    4/6 
  Installing : mysql-community-libs-compat-8.0.16-2.el7.x86_64                                                                                                                                                                               5/6 
  Erasing    : 1:mariadb-libs-5.5.60-1.el7_5.x86_64                                                                                                                                                                                          6/6 
  Verifying  : mysql-community-libs-8.0.16-2.el7.x86_64                                                                                                                                                                                      1/6 
  Verifying  : mysql-community-libs-compat-8.0.16-2.el7.x86_64                                                                                                                                                                               2/6 
  Verifying  : mysql-community-client-8.0.16-2.el7.x86_64                                                                                                                                                                                    3/6 
  Verifying  : mysql-community-common-8.0.16-2.el7.x86_64                                                                                                                                                                                    4/6 
  Verifying  : mysql-community-server-8.0.16-2.el7.x86_64                                                                                                                                                                                    5/6 
  Verifying  : 1:mariadb-libs-5.5.60-1.el7_5.x86_64                                                                                                                                                                                          6/6 

Installed:
  mysql-community-client.x86_64 0:8.0.16-2.el7   mysql-community-common.x86_64 0:8.0.16-2.el7   mysql-community-libs.x86_64 0:8.0.16-2.el7   mysql-community-libs-compat.x86_64 0:8.0.16-2.el7   mysql-community-server.x86_64 0:8.0.16-2.el7  

Replaced:
  mariadb-libs.x86_64 1:5.5.60-1.el7_5                                                                                                                                                                                                           

Complete!

 

到此就安装结束,下面开启防火墙端口3306并启动。开启防火墙端口是希望外界可以访问。

[root@localhost mysql8]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
success
[root@localhost mysql8]# systemctl restart firewalld
[root@localhost mysql8]# systemctl start mysqld
[root@localhost mysql8]# systemctl status mysqld
 mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2019-05-24 05:20:29 CST; 5s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 8804 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 8888 (mysqld)
   Status: "SERVER_OPERATING"
    Tasks: 38
   CGroup: /system.slice/mysqld.service
           └─8888 /usr/sbin/mysqld

May 24 05:20:14 localhost.localdomain systemd[1]: Starting MySQL Server...
May 24 05:20:29 localhost.localdomain systemd[1]: Started MySQL Server.

 

下面因为第一次启动,需要修改密码。

[root@localhost mysql8]# cat /var/log/mysqld.log | grep password
2019-05-23T21:20:25.393815Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: U3ZlzC>KAAc<
[root@localhost mysql8]# 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.16

Copyright (c) 2000, 2019, 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 'Abc123-S';
Query OK, 0 rows affected (0.02 sec)

 

到此安装以及初始化完毕,你可以在此执行一些SQL语句。

用Navicat连接

你要创建一个新用户并授权。

mysql> CREATE USER 'tom'@'%' IDENTIFIED BY 'Abc123-S';
Query OK, 0 rows affected (0.02 sec)

mysql> GRANT ALL ON *.* TO 'tom'@'%';
Query OK, 0 rows affected (0.02 sec)

 

连接的时候会出现

这是因为不支持当前的加密协议。MySQL8 创建用户默认使用caching_sha2_password,所以我们可以更改为MySQL5.7的mysql_native_password。

mysql> ALTER USER 'tom'@'%' IDENTIFIED WITH mysql_native_password BY 'Abc123-S';
Query OK, 0 rows affected (0.00 sec)

 

好了这次可以了

 

转载于:https://www.cnblogs.com/LUA123/p/10914712.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值