设为首页 收藏本站
查看: 752|回复: 0

[经验分享] CentOS7 使用yum安装mysql

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-11-3 09:25:42 | 显示全部楼层 |阅读模式
1、安装libaio
yum install libaio

2、卸载mariadb
yum removemariadb-libs-5.5.41-2.el7_0.x86_64

3、下载mysql yumrepository
wgethttp://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

4、添加Mysql yumrepository到系统列表的中,执行
yum localinstallmysql-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...


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-294997-1-1.html 上篇帖子: centos7离线安装mysql5.6.34 下篇帖子: MySQL 基本语句 mysql
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表