1.运行环境
- centos7 64位
- VMware14
- MySQL Community Server 5.6.43
2.安装mysql
2.1 检查是否已安装mysql
yum list installed | grep mysql
如果已安装,使用如下命令删除,【mysql****】为查找出的mysql依赖
yum -y remove mysql****
2.2 下载mysql
wget dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
2.3 安装
yum install mysql-community-release-el6-5.noarch.rpm
安装 mysql-community-server
yum install mysql-community-server
下载,安装输出内容如下
[root@localhost software]# wget dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
--2019-02-02 13:50:07-- http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
正在解析主机 dev.mysql.com (dev.mysql.com)... 137.254.60.11
正在连接 dev.mysql.com (dev.mysql.com)|137.254.60.11|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 301 Moved Permanently
位置:https://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm [跟随至新的 URL]
--2019-02-02 13:50:08-- https://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
正在连接 dev.mysql.com (dev.mysql.com)|137.254.60.11|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 302 Found
位置:https://repo.mysql.com//mysql-community-release-el6-5.noarch.rpm [跟随至新的 URL]
--2019-02-02 13:50:09-- https://repo.mysql.com//mysql-community-release-el6-5.noarch.rpm
正在解析主机 repo.mysql.com (repo.mysql.com)... 23.1.187.107
正在连接 repo.mysql.com (repo.mysql.com)|23.1.187.107|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:5824 (5.7K) [application/x-redhat-package-manager]
正在保存至: “mysql-community-release-el6-5.noarch.rpm”
100%[==========================================================================================================================>] 5,824 --.-K/s 用时 0s
2019-02-02 13:50:09 (95.2 MB/s) - 已保存 “mysql-community-release-el6-5.noarch.rpm” [5824/5824])
[root@localhost software]# ls
erlang-20.3-1.el6.x86_64.rpm mysql-community-release-el6-5.noarch.rpm rabbitmq-server-3.7.7-1.el7.noarch.rpm
[root@localhost software]# yum install mysql-community-release-el6-5.noarch.rpm
已加载插件:fastestmirror, langpacks
正在检查 mysql-community-release-el6-5.noarch.rpm: mysql-community-release-el6-5.noarch
mysql-community-release-el6-5.noarch.rpm 将被安装
正在解决依赖关系
--> 正在检查事务
---> 软件包 mysql-community-release.noarch.0.el6-5 将被 安装
--> 解决依赖关系完成
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
updates/7/x86_64/primary_db | 2.4 MB 00:00:02
依赖关系解决
====================================================================================================================================================================
Package 架构 版本 源 大小
====================================================================================================================================================================
正在安装:
mysql-community-release noarch el6-5 /mysql-community-release-el6-5.noarch 4.3 k
事务概要
====================================================================================================================================================================
安装 1 软件包
总计:4.3 k
安装大小:4.3 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : mysql-community-release-el6-5.noarch 1/1
验证中 : mysql-community-release-el6-5.noarch 1/1
已安装:
mysql-community-release.noarch 0:el6-5
完毕!
[root@localhost software]# yum install mysql-community-server
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirror01.idc.hinet.net
mysql-connectors-community | 2.5 kB 00:00:00
mysql-tools-community | 2.5 kB 00:00:00
mysql56-community | 2.5 kB 00:00:00
(1/3): mysql-connectors-community/x86_64/primary_db | 33 kB 00:00:00
(2/3): mysql-tools-community/x86_64/primary_db | 48 kB 00:00:00
(3/3): mysql56-community/x86_64/primary_db | 251 kB 00:00:00
正在解决依赖关系
--> 正在检查事务
---> 软件包 mysql-community-server.x86_64.0.5.6.43-2.el6 将被 安装
--> 正在处理依赖关系 mysql-community-common(x86-64) = 5.6.43-2.el6,它被软件包 mysql-community-server-5.6.43-2.el6.x86_64 需要
--> 正在处理依赖关系 mysql-community-client(x86-64) >= 5.6.10,它被软件包 mysql-community-server-5.6.43-2.el6.x86_64 需要
--> 正在检查事务
---> 软件包 mysql-community-client.x86_64.0.5.6.43-2.el6 将被 安装
--> 正在处理依赖关系 mysql-community-libs(x86-64) >= 5.6.10,它被软件包 mysql-community-client-5.6.43-2.el6.x86_64 需要
---> 软件包 mysql-community-common.x86_64.0.5.6.43-2.el6 将被 安装
--> 正在检查事务
---> 软件包 mariadb-libs.x86_64.1.5.5.56-2.el7 将被 取代
---> 软件包 mysql-community-libs.x86_64.0.5.6.43-2.el6 将被 舍弃
--> 解决依赖关系完成
依赖关系解决
====================================================================================================================================================================
Package 架构 版本 源 大小
====================================================================================================================================================================
正在安装:
mysql-community-libs x86_64 5.6.43-2.el6 mysql56-community 1.9 M
替换 mariadb-libs.x86_64 1:5.5.56-2.el7
mysql-community-server x86_64 5.6.43-2.el6 mysql56-community 55 M
为依赖而安装:
mysql-community-client x86_64 5.6.43-2.el6 mysql56-community 18 M
mysql-community-common x86_64 5.6.43-2.el6 mysql56-community 308 k
事务概要
====================================================================================================================================================================
安装 2 软件包 (+2 依赖软件包)
总下载量:75 M
Is this ok [y/d/N]: y
Downloading packages:
警告:/var/cache/yum/x86_64/7/mysql56-community/packages/mysql-community-common-5.6.43-2.el6.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY:03:59 ETA
mysql-community-common-5.6.43-2.el6.x86_64.rpm 的公钥尚未安装
(1/4): mysql-community-common-5.6.43-2.el6.x86_64.rpm | 308 kB 00:00:00
(2/4): mysql-community-libs-5.6.43-2.el6.x86_64.rpm | 1.9 MB 00:00:04
(3/4): mysql-community-client-5.6.43-2.el6.x86_64.rpm | 18 MB 00:00:39
(4/4): mysql-community-server-5.6.43-2.el6.x86_64.rpm | 55 MB 00:01:16
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计 935 kB/s | 75 MB 00:01:22
从 file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql 检索密钥
导入 GPG key 0x5072E1F5:
用户ID : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
指纹 : a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
软件包 : mysql-community-release-el6-5.noarch (installed)
来自 : file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
是否继续?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : mysql-community-common-5.6.43-2.el6.x86_64 1/5
正在安装 : mysql-community-libs-5.6.43-2.el6.x86_64 2/5
正在安装 : mysql-community-client-5.6.43-2.el6.x86_64 3/5
正在安装 : mysql-community-server-5.6.43-2.el6.x86_64 4/5
正在删除 : 1:mariadb-libs-5.5.56-2.el7.x86_64 5/5
验证中 : mysql-community-server-5.6.43-2.el6.x86_64 1/5
验证中 : mysql-community-libs-5.6.43-2.el6.x86_64 2/5
验证中 : mysql-community-common-5.6.43-2.el6.x86_64 3/5
验证中 : mysql-community-client-5.6.43-2.el6.x86_64 4/5
验证中 : 1:mariadb-libs-5.5.56-2.el7.x86_64 5/5
已安装:
mysql-community-libs.x86_64 0:5.6.43-2.el6 mysql-community-server.x86_64 0:5.6.43-2.el6
作为依赖被安装:
mysql-community-client.x86_64 0:5.6.43-2.el6 mysql-community-common.x86_64 0:5.6.43-2.el6
替代:
mariadb-libs.x86_64 1:5.5.56-2.el7
完毕!
此时,mysql安装完毕!
3登录mysql
3.1 启动mysql服务
systemctl start mysqld.service #启动mysql服务
systemctl status mysqld.service #查看mysql服务状态
#结果如下
mysqld.service - SYSV: MySQL database server.
Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled)
Active: active (running) since 六 2019-02-02 13:53:51 CST; 37min ago
Docs: man:systemd-sysv-generator(8)
Process: 3343 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=0/SUCCESS)
Main PID: 3647
Tasks: 26
CGroup: /system.slice/mysqld.service
├─3443 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr -...
└─5802 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/log/mysqld.log --pi...
查看启动结果,查看mysql端口
systemctl status mysqld.service
#查看结果如下 看到3306端口已启动
#tcp6 0 0 :::3306 :::* LISTEN 5802/mysqld
3.2 登录
需要更改密码,使用如下命令:
use mysql;
update user set password=password("password") where user="用户名";
#无密码登录
mysql -u root #-u表示使用用户名root登录
#有密码登录
mysql -u root -p #-u表示使用用户名root使用密码登录
#如下表示登录成功
[root@localhost software]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.6.43 MySQL Community Server (GPL)
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.
3.3 使用Navicat登录
登录可能会有1103异常,修改root的权限即可解决
error1103:Host *.*.*.* is not allowed to connect
首先登录mysql,后插入host=‘%’的用户,表示所有都可以链接
INSERT INTO user(host, user, password, select_priv, insert_priv, update_priv) VALUES ('%', 'username', PASSWORD(‘yourpassword'), 'Y', 'Y','Y');
重新启动mysql后如果有1045异常,重新执行修改密码即可链接。