CentOS7 使用yum安装mysql

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
云数据库 RDS MySQL Serverless,价值2615元额度,1个月
简介:

1、安装libaio

yum install libaio

 

2、卸载mariadb

yum  remove  mariadb-libs-5.5.41-2.el7_0.x86_64

 

3、下载mysql yumrepository

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

 

4、添加Mysql yumrepository到系统列表的中,执行

yum localinstall  mysql-community-release-el7-5.noarch.rpm

 

5、查看yum源中的版本

yum repolist all | grep mysql

mysql-connectors-community/x86_64 MySQLConnectors Community         启用:    24

mysql-connectors-community-source MySQLConnectors Community - Sourc 禁用

mysql-tools-community/x86_64      MySQL Tools Community              启用:    38

mysql-tools-community-source      MySQL Tools Community - Source     禁用

mysql55-community/x86_64          MySQL 5.5 Community Server         禁用

mysql55-community-source          MySQL 5.5 Community Server - Sourc 禁用

mysql56-community/x86_64          MySQL 5.6 Community Server         启用:   289

mysql56-community-source          MySQL 5.6 Community Server - Sourc 禁用

mysql57-community-dmr/x86_64      MySQL 5.7 Community Server Develop 禁用

mysql57-community-dmr-source      MySQL 5.7 Community Server Develop 禁用

 

6、可以通过修改/etc/yum.repos.d/mysql-community.repo文件来决定启用哪个版本,例如启用下面的版本

# Enable to use MySQL 5.6

[mysql56-community]

name=MySQL 5.6 Community Server

baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/

enabled=1

gpgcheck=1

gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

 

7、查看启用的哪个版本

yum repolist enabled | grep mysql

mysql-connectors-community/x86_64        MySQL Connectors Community           24

mysql-tools-community/x86_64             MySQL Tools Community                38

mysql56-community/x86_64                 MySQL 5.6 CommunityServer          289

 

8、安装mysql,执行下面的命令

yum install mysql-community-server

需要安装下图所示的包

依赖关系解决

 

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

 Package                                   架构                     版本                                                                  大小

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

正在安装:

 mysql-community-server                    x86_64                   5.6.34-2.el7                       mysql56-community                    59 M

为依赖而安装:

 mysql-community-client                    x86_64                   5.6.34-2.el7                       mysql56-community                    19 M

 mysql-community-common                    x86_64                   5.6.34-2.el7                       mysql56-community                   257 k

 mysql-community-libs                      x86_64                   5.6.34-2.el7                       mysql56-community                   2.0 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-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

 

9、启动mysql

systemctl start mysqld

 

10、查看mysql状态

systemctl status mysqld

 

mysqld.service - MySQL Community Server

  Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)

  Active: active (running) since  2016-10-29 03:57:59CST; 56s ago

 Process: 4549 ExecStartPost=/usr/bin/mysql-systemd-start post(code=exited, status=0/SUCCESS)

 Process: 4489 ExecStartPre=/usr/bin/mysql-systemd-start pre(code=exited, status=0/SUCCESS)

 MainPID: 4548 (mysqld_safe)

  CGroup: /system.slice/mysqld.service

          ├─4548 /bin/sh /usr/bin/mysqld_safe

          └─4701 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql--plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mys...

 

10 29 03:57:57localhost.localdomain mysql-systemd-start[4489]: Support MySQL by buyingsupport/licenses at http://shop.mysql.com

10 29 03:57:57localhost.localdomain mysql-systemd-start[4489]: Note: new default config filenot created.

10 29 03:57:57localhost.localdomain mysql-systemd-start[4489]: Please make sure your configfile is current

10 29 03:57:57localhost.localdomain mysql-systemd-start[4489]: WARNING: Default config file/etc/my.cnf exists on the system

10 29 03:57:57localhost.localdomain mysql-systemd-start[4489]: This file will be read bydefault by the MySQL server

10 29 03:57:57localhost.localdomain mysql-systemd-start[4489]: If you do not want to usethis, either remove it, or use the

10 29 03:57:57localhost.localdomain mysql-systemd-start[4489]: --defaults-file argument tomysqld_safe when starting the server

10 29 03:57:57localhost.localdomain mysqld_safe[4548]: 161029 03:57:57 mysqld_safe Logging to'/var/log/mysqld.log'.

10 29 03:57:58 localhost.localdomainmysqld_safe[4548]: 161029 03:57:58 mysqld_safe Starting mysqld daemon withdatabases from /...mysql

10 29 03:57:59localhost.localdomain systemd[1]: Started MySQL Community Server.

Hint: Some lines were ellipsized, use -l toshow in full.

 

11、测试安装是否成功

mysql可以正常的登入

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

Your MySQL connection id is 2

Server version: 5.6.34 MySQL CommunityServer (GPL)

 

Copyright (c) 2000, 2016, Oracle and/or itsaffiliates. All rights reserved.

 

Oracle is a registered trademark of OracleCorporation and/or its

affiliates. Other names may be trademarksof their respective

owners.

 

Type 'help;' or '\h' for help. Type '\c' toclear the current input statement.

 

mysql>

 

12、关闭firewall,禁止firewall开机启动

systemctl stop firewalld.service

systemctl disable firewalld.service

 

13、安装iptables防火墙,并启用iptables

yum install iptables-services

service iptables start

 

14、mysql 安全设置

执行mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FORALL MySQL

      SERVERS INPRODUCTION USE!  PLEASE READ EACH STEPCAREFULLY!

 

In order to log into MySQL to secure it, we'll need thecurrent

password for the root user. If you've just installed MySQL, and

you haven't set the root password yet, the password will beblank,

so you should just press enter here.

 

Enter current password for root (enter for none):

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

Enter current password for root (enter for none):

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

Enter current password for root (enter for none):

OK, successfully used password, moving on...

 

Setting the root password ensures that nobody can log intothe MySQL

root user without the proper authorisation.

 

Set root password? [Y/n] Y

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

 ... Success!

 

 

By default, a MySQL installation has an anonymous user,allowing anyone

to log into MySQL without having to have a user accountcreated for

them.  This isintended only for testing, and to make the installation

go a bit smoother. You should remove them before moving into a

production environment.

 

Remove anonymous users? [Y/n] y

 ... Success!

 

Normally, root should only be allowed to connect from'localhost'.  This

ensures that someone cannot guess at the root password fromthe network.

 

Disallow root login remotely? [Y/n] n 

 ... skipping.

 

By default, MySQL comes with a database named 'test' thatanyone can

access.  This is alsointended only for testing, and should be removed

before moving into a production environment.

 

Remove test database and access to it? [Y/n] y

 - Dropping testdatabase...

ERROR 1008 (HY000) at line 1: Can't drop database 'test';database doesn't exist

 ... Failed!  Not critical, keep moving...

 - Removingprivileges on test database...

 ... Success!

 

Reloading the privilege tables will ensure that all changesmade so far

will take effect immediately.

 

Reload privilege tables now? [Y/n] y

 ... Success!

 

 

 

 

All done!  If you'vecompleted all of the above steps, your MySQL

installation should now be secure.

 

Thanks for using MySQL!

 

 

Cleaning up...

本文转自服务器运维博客51CTO博客,原文链接http://blog.51cto.com/shamereedwine/1868452如需转载请自行联系原作者


neijiade10000

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
3天前
|
运维 安全 Linux
如何在CentOS7一键安装宝塔面板并实现固定地址访问内网宝塔进行管理
如何在CentOS7一键安装宝塔面板并实现固定地址访问内网宝塔进行管理
|
3天前
|
Linux 测试技术 数据安全/隐私保护
CentOS安装MeterSphere并实现无公网IP远程访问本地测试平台
CentOS安装MeterSphere并实现无公网IP远程访问本地测试平台
|
3天前
|
SQL 关系型数据库 MySQL
【MySQL-3】图形化界面工具DataGrip安装&配置&使用
【MySQL-3】图形化界面工具DataGrip安装&配置&使用
|
3天前
|
关系型数据库 MySQL Linux
【MySQL-2】MySQL的下载&安装&启停&配置环境变量【一条龙教程】
【MySQL-2】MySQL的下载&安装&启停&配置环境变量【一条龙教程】
|
4天前
|
Linux Docker 容器
centos7安装docker图文详解
该文档提供了在CentOS上安装Docker的步骤:检查系统内核版本(需大于3.10),更新yum,卸载旧版Docker,安装yum-utils和依赖包,设置Docker仓库,列出并选择Docker版本,安装Docker,最后启动并设置Docker开机启动,通过`docker version`验证安装是否成功。
|
5天前
|
弹性计算 关系型数据库 MySQL
在线安装MySQL5.7和MySQL8.0
【4月更文挑战第30天】
15 0
|
3月前
|
关系型数据库 MySQL Linux
centos7.0环境下安装MySql_8.0.12
centos7.0环境下安装MySql_8.0.12
|
3月前
|
缓存 关系型数据库 MySQL
百度搜索:蓝易云【CentOS8服务器安装MySQL报错:no match mysql-community-server】
现在,你已经成功安装了MySQL服务器并解决了"no match mysql-community-server"的报错问题。祝你使用愉快!
43 1
|
4月前
|
关系型数据库 MySQL Unix
CentOS安装MySQL5.5
CentOS安装MySQL5.5
88 0
|
3月前
|
关系型数据库 MySQL Linux
CentOS7环境下安装MySQL5.6
CentOS7环境下安装MySQL5.6
204 0