检查系统中是否已安装 MySQL。

rpm -qa | grep mysql

返回空值的话,就说明没有安装 MySQL

查看已安装的 Mariadb 数据库版本

# rpm -qa|grep -i mariadb

mariadb-libs-5.5.60-1.el7_5.x86_64

卸载已安装的 Mariadb 数据库

rpm -qa|grep mariadb|xargs rpm -e --nodeps

再次查看已安装的 Mariadb 数据库版本,确认是否卸载完成

rpm -qa|grep -i mariadb

下载安装包文件

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

安装mysql-community-release-el7-5.noarch.rpm包

rpm -ivh mysql-community-release-el7-5.noarch.rpm

安装完成之后,会在 /etc/yum.repos.d/ 目录下新增 mysql-community.repo 、mysql-community-source.repo 两个 yum 源文件

[root@bogon yum.repos.d]# ls

CentOS-Base.repo CentOS-Sources.repo ius.repo

CentOS-CR.repo CentOS-Vault.repo ius-testing.repo

CentOS-Debuginfo.repo epel.repo mysql-community.repo

CentOS-fasttrack.repo epel-testing.repo mysql-community-source.repo

CentOS-Media.repo ius-archive.repo

执行 yum repolist all | grep mysql 命令查看可用的 mysql 安装文件

[root@bogon yum.repos.d]# yum repolist all | grep mysql

mysql-connectors-community/x86_64 MySQL Connectors Community enabled: 131

mysql-connectors-community-source MySQL Connectors Community - S disabled

mysql-tools-community/x86_64 MySQL Tools Community enabled: 100

mysql-tools-community-source MySQL Tools Community - Source disabled

mysql55-community/x86_64 MySQL 5.5 Community Server disabled

mysql55-community-source MySQL 5.5 Community Server - S disabled

mysql56-community/x86_64 MySQL 5.6 Community Server enabled: 496

mysql56-community-source MySQL 5.6 Community Server - S disabled

mysql57-community-dmr/x86_64 MySQL 5.7 Community Server Dev disabled

mysql57-community-dmr-source MySQL 5.7 Community Server Dev disabled

安装mysql

yum install mysql-server

[root@bogon yum.repos.d]# yum install mysql-server

Loaded plugins: fastestmirror, langpacks

Loading mirror speeds from cached hostfile

* base: mirror.bit.edu.cn

* epel: fedora.cs.nctu.edu.tw

* extras: mirrors.huaweicloud.com

* updates: mirror.bit.edu.cn

Resolving Dependencies

--> Running transaction check

---> Package mysql-community-server.x86_64 0:5.6.46-2.el7 will be installed

--> Processing Dependency: mysql-community-common(x86-64) = 5.6.46-2.el7 for package: mysql-community-server-5.6.46-2.el7.x86_64

--> Processing Dependency: mysql-community-client(x86-64) >= 5.6.10 for package: mysql-community-server-5.6.46-2.el7.x86_64

--> Processing Dependency: perl(Data::Dumper) for package: mysql-community-server-5.6.46-2.el7.x86_64

--> Processing Dependency: perl(DBI) for package: mysql-community-server-5.6.46-2.el7.x86_64

--> Running transaction check

---> Package mysql-community-client.x86_64 0:5.6.46-2.el7 will be installed

--> Processing Dependency: mysql-community-libs(x86-64) >= 5.6.10 for package: mysql-community-client-5.6.46-2.el7.x86_64

---> Package mysql-community-common.x86_64 0:5.6.46-2.el7 will be installed

---> Package perl-DBI.x86_64 0:1.627-4.el7 will be installed

--> Processing Dependency: perl(RPC::PlServer) >= 0.2001 for package: perl-DBI-1.627-4.el7.x86_64

--> Processing Dependency: perl(RPC::PlClient) >= 0.2000 for package: perl-DBI-1.627-4.el7.x86_64

---> Package perl-Data-Dumper.x86_64 0:2.145-3.el7 will be installed

--> Running transaction check

---> Package mysql-community-libs.x86_64 0:5.6.46-2.el7 will be installed

---> Package perl-PlRPC.noarch 0:0.2020-14.el7 will be installed

--> Processing Dependency: perl(Net::Daemon) >= 0.13 for package: perl-PlRPC-0.2020-14.el7.noarch

--> Processing Dependency: perl(Net::Daemon::Test) for package: perl-PlRPC-0.2020-14.el7.noarch

--> Processing Dependency: perl(Net::Daemon::Log) for package: perl-PlRPC-0.2020-14.el7.noarch

--> Processing Dependency: perl(Compress::Zlib) for package: perl-PlRPC-0.2020-14.el7.noarch

--> Running transaction check

---> Package perl-IO-Compress.noarch 0:2.061-2.el7 will be installed

--> Processing Dependency: perl(Compress::Raw::Zlib) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch

--> Processing Dependency: perl(Compress::Raw::Bzip2) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch

---> Package perl-Net-Daemon.noarch 0:0.48-5.el7 will be installed

--> Running transaction check

---> Package perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 will be installed

---> Package perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 will be installed

--> Finished Dependency Resolution

/var/cache/yum/x86_64/7/base/gen/comps.xml: no element found: line 1, column 0

Dependencies Resolved

================================================================================

Package Arch Version Repository Size

================================================================================

Installing:

mysql-community-server x86_64 5.6.46-2.el7 mysql56-community 86 M

Installing for dependencies:

mysql-community-client x86_64 5.6.46-2.el7 mysql56-community 39 M

mysql-community-common x86_64 5.6.46-2.el7 mysql56-community 289 k

mysql-community-libs x86_64 5.6.46-2.el7 mysql56-community 4.1 M

perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 base 32 k

perl-Compress-Raw-Zlib x86_64 1:2.061-4.el7 base 57 k

perl-DBI x86_64 1.627-4.el7 base 802 k

perl-Data-Dumper x86_64 2.145-3.el7 base 47 k

perl-IO-Compress noarch 2.061-2.el7 base 260 k

perl-Net-Daemon noarch 0.48-5.el7 base 51 k

perl-PlRPC noarch 0.2020-14.el7 base 36 k

Transaction Summary

================================================================================

Install 1 Package (+10 Dependent packages)

Total download size: 130 M

Installed size: 527 M

Is this ok [y/d/N]: y

Downloading packages:

warning: /var/cache/yum/x86_64/7/mysql56-community/packages/mysql-community-common-5.6.46-2.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Public key for mysql-community-common-5.6.46-2.el7.x86_64.rpm is not installed

(1/11): mysql-community-common-5.6.46-2.el7.x86_64.rpm | 289 kB 00:01

(2/11): mysql-community-libs-5.6.46-2.el7.x86_64.rpm | 4.1 MB 00:01

(3/11): perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm | 32 kB 00:00

(4/11): perl-DBI-1.627-4.el7.x86_64.rpm | 802 kB 00:00

(5/11): perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm | 57 kB 00:00

(6/11): perl-IO-Compress-2.061-2.el7.noarch.rpm | 260 kB 00:00

(7/11): perl-Data-Dumper-2.145-3.el7.x86_64.rpm | 47 kB 00:00

(8/11): perl-Net-Daemon-0.48-5.el7.noarch.rpm | 51 kB 00:00

(9/11): perl-PlRPC-0.2020-14.el7.noarch.rpm | 36 kB 00:00

(10/11): mysql-community-client-5.6.46-2.el7.x86_64.rpm | 39 MB 00:08

(11/11): mysql-community-server-5.6.46-2.el7.x86_64.rpm | 86 MB 00:17

--------------------------------------------------------------------------------

Total 6.5 MB/s | 130 MB 00:19

Retrieving key from file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

Importing GPG key 0x5072E1F5:

Userid : "MySQL Release Engineering "

Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5

Package : mysql-community-release-el7-5.noarch (installed)

From : file:/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.

** Found 2 pre-existing rpmdb problem(s), 'yum check' output follows:

2:postfix-2.10.1-7.el7.x86_64 has missing requires of libmysqlclient.so.18()(64bit)

2:postfix-2.10.1-7.el7.x86_64 has missing requires of libmysqlclient.so.18(libmysqlclient_18)(64bit)

Installing : mysql-community-common-5.6.46-2.el7.x86_64 1/11

Installing : perl-Data-Dumper-2.145-3.el7.x86_64 2/11

Installing : mysql-community-libs-5.6.46-2.el7.x86_64 3/11

Installing : mysql-community-client-5.6.46-2.el7.x86_64 4/11

Installing : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 5/11

Installing : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 6/11

Installing : perl-IO-Compress-2.061-2.el7.noarch 7/11

Installing : perl-Net-Daemon-0.48-5.el7.noarch 8/11

Installing : perl-PlRPC-0.2020-14.el7.noarch 9/11

Installing : perl-DBI-1.627-4.el7.x86_64 10/11

Installing : mysql-community-server-5.6.46-2.el7.x86_64 11/11

Verifying : perl-Net-Daemon-0.48-5.el7.noarch 1/11

Verifying : perl-Data-Dumper-2.145-3.el7.x86_64 2/11

Verifying : mysql-community-libs-5.6.46-2.el7.x86_64 3/11

Verifying : perl-IO-Compress-2.061-2.el7.noarch 4/11

Verifying : mysql-community-server-5.6.46-2.el7.x86_64 5/11

Verifying : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 6/11

Verifying : mysql-community-common-5.6.46-2.el7.x86_64 7/11

Verifying : perl-DBI-1.627-4.el7.x86_64 8/11

Verifying : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 9/11

Verifying : perl-PlRPC-0.2020-14.el7.noarch 10/11

Verifying : mysql-community-client-5.6.46-2.el7.x86_64 11/11

Installed:

mysql-community-server.x86_64 0:5.6.46-2.el7

Dependency Installed:

mysql-community-client.x86_64 0:5.6.46-2.el7

mysql-community-common.x86_64 0:5.6.46-2.el7

mysql-community-libs.x86_64 0:5.6.46-2.el7

perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7

perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7

perl-DBI.x86_64 0:1.627-4.el7

perl-Data-Dumper.x86_64 0:2.145-3.el7

perl-IO-Compress.noarch 0:2.061-2.el7

perl-Net-Daemon.noarch 0:0.48-5.el7

perl-PlRPC.noarch 0:0.2020-14.el7

Complete!

[root@bogon yum.repos.d]#

检查mysql是否安装成功

rpm -qa | grep mysql

[root@bogon yum.repos.d]# rpm -qa | grep mysql

mysql-community-client-5.6.46-2.el7.x86_64

mysql-community-common-5.6.46-2.el7.x86_64

mysql-community-release-el7-5.noarch

mysql-community-libs-5.6.46-2.el7.x86_64

mysql-community-server-5.6.46-2.el7.x86_64

启动 mysql 服务

systemctl start mysqld.service #启动 mysql

systemctl restart mysqld.service #重启 mysql

systemctl stop mysqld.service #停止 mysql

systemctl enable mysqld.service #设置 mysql 开机启动

设置密码

# mysql -u root

mysql> use mysql;

mysql> update user set password=PASSWORD("这里输入root用户密码") where User='root';

mysql> flush privileges;

例如:

[root@bogon yum.repos.d]# mysql -u root

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.6.46 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.

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> update user set password=PASSWORD("root") where User='root';

Query OK, 4 rows affected (0.00 sec)

Rows matched: 4 Changed: 4 Warnings: 0

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> quit

Bye

[root@bogon yum.repos.d]# mysql -u root

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

[root@bogon yum.repos.d]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 4

Server version: 5.6.46 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.

mysql> create database mydb;

Query OK, 1 row affected (0.01 sec)

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| mydb |

| performance_schema |

+--------------------+

4 rows in set (0.00 sec)

mysql>

设置远程主机登录

mysql> GRANT ALL PRIVILEGES ON *.* TO 'your username'@'%' IDENTIFIED BY 'your password';

执行以下命令,为root 用户添加远程登录的能力。

mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root";

centos5.6安装mysql,Centos下安装mysql5.6相关推荐

  1. linux nginx rpm 安装配置,Centos下安装nginx rpm包

    1 在nginx官方网站下载一个rpm包,下载地址是:http://nginx.org/en/download.html wget http://nginx.org/packages/centos/6 ...

  2. nginx 怎么重新编译安装mysql,centos 下 编译安装 nginx + mysql + php 服务

    centos 下编译安装nginx + mysql + php 服务 1.安装nginx 1.1.安装依赖包 yum install wget make gcc gcc-c++ pcre-devel ...

  3. linux yum 安装vsftp,CentOS下安装安装vsftp

    最近正在学习linux,忽然想起自己搭建一个ftp服务器.在网上看过一些资料后,开始动手,仅作为在初始学习时的一个笔记,偶尔帮助记忆,希望高手看后莫笑~ 搭建环境:win7系统下安装vmware工作站 ...

  4. centos下安装 php,Centos 下安装 PHP (新)

    今天重新实践了下 CentOS 7.6 下安装 PHP7 并完成配置,总结了一条可以照其实现的套路. 安装 PHP 所需扩展# yum install libxml2 libxml2-devel op ...

  5. ubintu yum装mysql_Ubuntu 下安装Mysql centos8 下安装mysql8.0

    sudo apt-get install mysql-server-5.7  # 安装mysql apt install net-tools  #安装 sudo ufw status #查看防火墙是否 ...

  6. 自定义安装mysql linux_linux下 安装mysql 问题

    展开全部 因为32313133353236313431303231363533e4b893e5b19e31333365633934mysql程序在启动的时候  非常依赖my.cnf里面的配置,而my. ...

  7. 安装MySQL 64_windows下安装mysql-8.0.18-winx64

    1.下载安装包 安装包现在地址: 2.解压缩至安装目录 解压缩下载之后的zip,我这里使用的安装路径为: C:\Program Files\mysql-8.0.18-winx64 解压缩之后,需要在安 ...

  8. centos 7 ssh 安装mysql,Centos 7 安装Airflow

    Airflow 安装环境 : centos7   python3.7.0  mysql-8.0.22 一.安装mysql-8.0.22 二.安装python3.7.0 三.安装配置 [root@had ...

  9. adb zip linux 安装教程,centos下安装adb环境

    1.安装adb,步骤如下 wget https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip unzip sdk-too ...

最新文章

  1. 解决方案仅用于执行startup.bat启动时乱码解决
  2. 以整体思维看问题:解决单页应用,系统角色请求覆盖身份唯一标识(本项目中是session_id命名的)发送请求问题...
  3. dotNET Core 3.X 请求处理管道和中间件的理解
  4. threadlocal_了解ThreadLocal背后的概念
  5. 2020年中国人工智能商业落地研究报告
  6. 网页设计图片向上浮动_HTML5 背景图片漂浮/浮动特效
  7. 0day影响 Chrome和 Safari,谷歌不修复
  8. L3-012 水果忍者 (30 分)-PAT 团体程序设计天梯赛 GPLT
  9. 计算机主板型号进bios,什么是BIOS?
  10. 阿里启动“Buy+”计划,正式成立 VR 实验室
  11. 基于springboot vue h5 手机商城源码
  12. JAVA 分布式 - 分布式介绍
  13. Linux 常用的软件包管理器/软件包管理工具详解
  14. 如何使用QT?步骤详解
  15. Java 字符串处理
  16. C++线索二叉树(中序线索二叉树及遍历)
  17. python通过QQ邮箱或163邮箱发送邮件(可带附件)
  18. 京版国八条终于出来了——京十五条
  19. 数据库开启遇到的keng
  20. ILI9341的使用之【五】命令一

热门文章

  1. 关于移动广告平台,你不知道的那些事
  2. 中欧MiniMBA-建设高效团队
  3. Unity虚拟相机控制中心 CinemachineBrain
  4. 关于 URLLC场景下的 the Short Blocklength Regime
  5. 华硕 内存条 不同步_双11还没到,价格战就已打响,酷兽RGB灯条直接杀价至379元|内存条|内存|台式机|酷兽|rgb...
  6. OS_@假脱机技术@设备分配@设备映射
  7. 【bzoj2073】[POI2004]PRZ
  8. Bzoj2073 [POI2004] PRZ
  9. 【Scratch案例实操】Scratch小鸡吃虫 scratch编程案例教学 scratch创意编程 少儿编程教案
  10. java后端初中级工程师换工作小结