侯体宗的博客
  • 首页
  • Hyperf版
  • beego仿版
  • 人生(杂谈)
  • 技术
  • 关于我
  • 更多分类
    • 文件下载
    • 文字修仙
    • 中国象棋ai
    • 群聊
    • 九宫格抽奖
    • 拼图
    • 消消乐
    • 相册

centos 6.9安装mysql的详细教程

linux  /  管理员 发布于 7年前   213

1、确认mysql是否已安装,有下面的代码可知

[root@cdh1 zjl]# yum list installed mysql*Loaded plugins: fastestmirror, refresh-packagekit, securityLoading mirror speeds from cached hostfile * base: mirrors.zju.edu.cn * extras: mirrors.aliyun.com * updates: mirrors.aliyun.comInstalled PackagesMySQL-python.x86_64 1.2.3-0.3.c1.1.el6 @base      mysql-libs.x86_64 5.1.73-8.el6_8  @anaconda-CentOS-201703281317.x86_64/6.9

2、卸载已安装的mysql,建议使用yum命令,因为yum命令可以自动删除与mysql相关的依赖;如果使用rpm命令,则还需要手动去删除和mysql相关的文件,比较麻烦

[root@cdh1 zjl]# yum remove MySQL-python.x86_64 mysql-libs.x86_64Loaded plugins: fastestmirror, refresh-packagekit, securitySetting up Remove ProcessResolving Dependencies--> Running transaction check---> Package MySQL-python.x86_64 0:1.2.3-0.3.c1.1.el6 will be erased--> Processing Dependency: MySQL-python for package: cloudera-manager-agent-5.11.1-1.cm5111.p0.9.el6.x86_64---> Package mysql-libs.x86_64 0:5.1.73-8.el6_8 will be erased--> Processing Dependency: libmysqlclient.so.16()(64bit) for package: 2:postfix-2.6.6-8.el6.x86_64--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: 2:postfix-2.6.6-8.el6.x86_64--> Processing Dependency: mysql-libs for package: 2:postfix-2.6.6-8.el6.x86_64--> Running transaction check---> Package cloudera-manager-agent.x86_64 0:5.11.1-1.cm5111.p0.9.el6 will be erased---> Package postfix.x86_64 2:2.6.6-8.el6 will be erased--> Processing Dependency: /usr/sbin/sendmail for package: redhat-lsb-core-4.0-7.el6.centos.x86_64--> Processing Dependency: /usr/sbin/sendmail for package: cronie-1.4.4-16.el6_8.2.x86_64--> Running transaction check---> Package cronie.x86_64 0:1.4.4-16.el6_8.2 will be erased--> Processing Dependency: cronie = 1.4.4-16.el6_8.2 for package: cronie-anacron-1.4.4-16.el6_8.2.x86_64---> Package redhat-lsb-core.x86_64 0:4.0-7.el6.centos will be erased--> Processing Dependency: redhat-lsb-core(x86-64) = 4.0 for package: redhat-lsb-printing-4.0-7.el6.centos.x86_64--> Processing Dependency: redhat-lsb-core(x86-64) = 4.0-7.el6.centos for package: redhat-lsb-4.0-7.el6.centos.x86_64--> Processing Dependency: redhat-lsb-core(x86-64) = 4.0 for package: redhat-lsb-graphics-4.0-7.el6.centos.x86_64--> Running transaction check---> Package cronie-anacron.x86_64 0:1.4.4-16.el6_8.2 will be erased---> Package redhat-lsb.x86_64 0:4.0-7.el6.centos will be erased--> Processing Dependency: redhat-lsb(x86-64) = 4.0-7.el6.centos for package: redhat-lsb-compat-4.0-7.el6.centos.x86_64---> Package redhat-lsb-graphics.x86_64 0:4.0-7.el6.centos will be erased---> Package redhat-lsb-printing.x86_64 0:4.0-7.el6.centos will be erased--> Running transaction check---> Package redhat-lsb-compat.x86_64 0:4.0-7.el6.centos will be erased--> Processing Dependency: /etc/cron.d for package: crontabs-1.10-33.el6.noarch--> Processing Dependency: /etc/cron.d for package: sysstat-9.0.4-33.el6.x86_64--> Restarting Dependency Resolution with new changes.--> Running transaction check---> Package crontabs.noarch 0:1.10-33.el6 will be erased---> Package sysstat.x86_64 0:9.0.4-33.el6 will be erased--> Finished Dependency ResolutionDependencies Resolved==================================================================== Package    Arch Version     Repository    Size====================================================================Removing: MySQL-python   x86_64 1.2.3-0.3.c1.1.el6  @base 246 k mysql-libs    x86_64 5.1.73-8.el6_8   @anaconda-CentOS-201703281317.x86_64/6.9    4.0 MRemoving for dependencies: cloudera-manager-agent x86_64 5.11.1-1.cm5111.p0.9.el6 @/cloudera-manager-agent-5.11.1-1.cm5111.p0.9.el6.x86_64    71 M cronie     x86_64 1.4.4-16.el6_8.2   @anaconda-CentOS-201703281317.x86_64/6.9    174 k cronie-anacron   x86_64 1.4.4-16.el6_8.2   @anaconda-CentOS-201703281317.x86_64/6.9    43 k crontabs    noarch 1.10-33.el6    @anaconda-CentOS-201703281317.x86_64/6.9    2.4 k postfix    x86_64 2:2.6.6-8.el6   @anaconda-CentOS-201703281317.x86_64/6.9    9.7 M redhat-lsb    x86_64 4.0-7.el6.centos   @anaconda-CentOS-201703281317.x86_64/6.9    0.0  redhat-lsb-compat  x86_64 4.0-7.el6.centos   @anaconda-CentOS-201703281317.x86_64/6.9    0.0  redhat-lsb-core  x86_64 4.0-7.el6.centos   @anaconda-CentOS-201703281317.x86_64/6.9    22 k redhat-lsb-graphics x86_64 4.0-7.el6.centos   @anaconda-CentOS-201703281317.x86_64/6.9    0.0  redhat-lsb-printing x86_64 4.0-7.el6.centos   @anaconda-CentOS-201703281317.x86_64/6.9    0.0  sysstat    x86_64 9.0.4-33.el6    @anaconda-CentOS-201703281317.x86_64/6.9    826 kTransaction Summary====================================================================Remove  13 Package(s)Installed size: 86 MIs this ok [y/N]: yDownloading Packages:Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning TransactionWarning: RPMDB altered outside of yum. Erasing : redhat-lsb-compat-4.0-7.el6.centos.x86_64  1/13  Erasing : redhat-lsb-4.0-7.el6.centos.x86_64    2/13  Erasing : cloudera-manager-agent-5.11.1-1.cm5111.p0.9. 3/13 warning: /etc/cloudera-scm-agent/config.ini saved as /etc/cloudera-scm-agent/config.ini.rpmsave Erasing : redhat-lsb-graphics-4.0-7.el6.centos.x86_64  4/13  Erasing : redhat-lsb-printing-4.0-7.el6.centos.x86_64  5/13  Erasing : redhat-lsb-core-4.0-7.el6.centos.x86_64   6/13 /var/tmp/rpm-tmp.jLbJUk: line 1: lsb_release: command not found Erasing : MySQL-python-1.2.3-0.3.c1.1.el6.x86_64   7/13  Erasing : sysstat-9.0.4-33.el6.x86_64      8/13  Erasing : crontabs-1.10-33.el6.noarch      9/13  Erasing : cronie-anacron-1.4.4-16.el6_8.2.x86_64   10/13  Erasing : cronie-1.4.4-16.el6_8.2.x86_64     11/13  Erasing : 2:postfix-2.6.6-8.el6.x86_64     12/13  Erasing : mysql-libs-5.1.73-8.el6_8.x86_64    13/13  Verifying : redhat-lsb-printing-4.0-7.el6.centos.x86_64  1/13  Verifying : cronie-anacron-1.4.4-16.el6_8.2.x86_64   2/13  Verifying : cronie-1.4.4-16.el6_8.2.x86_64     3/13  Verifying : 2:postfix-2.6.6-8.el6.x86_64     4/13  Verifying : redhat-lsb-4.0-7.el6.centos.x86_64    5/13  Verifying : redhat-lsb-core-4.0-7.el6.centos.x86_64   6/13  Verifying : cloudera-manager-agent-5.11.1-1.cm5111.p0.9. 7/13  Verifying : crontabs-1.10-33.el6.noarch      8/13  Verifying : redhat-lsb-compat-4.0-7.el6.centos.x86_64  9/13  Verifying : MySQL-python-1.2.3-0.3.c1.1.el6.x86_64   10/13  Verifying : redhat-lsb-graphics-4.0-7.el6.centos.x86_64 11/13  Verifying : sysstat-9.0.4-33.el6.x86_64     12/13  Verifying : mysql-libs-5.1.73-8.el6_8.x86_64    13/13 Removed: MySQL-python.x86_64 0:1.2.3-0.3.c1.1.el6        mysql-libs.x86_64 0:5.1.73-8.el6_8        Dependency Removed: cloudera-manager-agent.x86_64 0:5.11.1-1.cm5111.p0.9.el6    cronie.x86_64 0:1.4.4-16.el6_8.2          cronie-anacron.x86_64 0:1.4.4-16.el6_8.2        crontabs.noarch 0:1.10-33.el6           postfix.x86_64 2:2.6.6-8.el6           redhat-lsb.x86_64 0:4.0-7.el6.centos         redhat-lsb-compat.x86_64 0:4.0-7.el6.centos       redhat-lsb-core.x86_64 0:4.0-7.el6.centos        redhat-lsb-graphics.x86_64 0:4.0-7.el6.centos       redhat-lsb-printing.x86_64 0:4.0-7.el6.centos       sysstat.x86_64 0:9.0.4-33.el6          Complete!

3、用whereis命令查找mysql相关的文件,因为步骤2用yum来卸载,所以mysql被清理得很干净;如果使用rpm将会很麻烦,有很多的文件需要手动清除

[root@cdh1 zjl]# whereis mysqlmysql:

4、查看系统中的mysql安装包

[root@cdh1 zjl]# yum list mysql*Loaded plugins: fastestmirror, refresh-packagekit, securityLoading mirror speeds from cached hostfile * base: mirrors.zju.edu.cn * extras: mirrors.aliyun.com * updates: mirrors.aliyun.comAvailable PackagesMySQL-python.x86_64          1.2.3-0.3.c1.1.el6        basemysql.x86_645.1.73-8.el6_8         basemysql-bench.x86_64           5.1.73-8.el6_8         basemysql-connector-java.noarch        1:5.1.17-6.el6         basemysql-connector-odbc.x86_64        5.1.5r1144-7.el6         basemysql-devel.i686           5.1.73-8.el6_8         basemysql-devel.x86_64           5.1.73-8.el6_8         basemysql-embedded.i686          5.1.73-8.el6_8         basemysql-embedded.x86_64          5.1.73-8.el6_8         basemysql-embedded-devel.i686         5.1.73-8.el6_8         basemysql-embedded-devel.x86_64        5.1.73-8.el6_8         basemysql-libs.i686           5.1.73-8.el6_8         basemysql-libs.x86_64           5.1.73-8.el6_8         basemysql-server.x86_64          5.1.73-8.el6_8         basemysql-test.x86_64           5.1.73-8.el6_8         base

5、选择mysql-server来安装

[root@cdh1 zjl]# yum install mysql-serverLoaded plugins: fastestmirror, refresh-packagekit, securitySetting up Install ProcessLoading mirror speeds from cached hostfile * base: mirrors.zju.edu.cn * extras: mirrors.aliyun.com * updates: mirrors.aliyun.comResolving Dependencies--> Running transaction check---> Package mysql-server.x86_64 0:5.1.73-8.el6_8 will be installed--> Processing Dependency: mysql = 5.1.73-8.el6_8 for package: mysql-server-5.1.73-8.el6_8.x86_64--> Processing Dependency: perl-DBI for package: mysql-server-5.1.73-8.el6_8.x86_64--> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1.73-8.el6_8.x86_64--> Processing Dependency: perl(DBI) for package: mysql-server-5.1.73-8.el6_8.x86_64--> Processing Dependency: libmysqlclient_r.so.16(libmysqlclient_16)(64bit) for package: mysql-server-5.1.73-8.el6_8.x86_64--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: mysql-server-5.1.73-8.el6_8.x86_64--> Processing Dependency: libmysqlclient_r.so.16()(64bit) for package: mysql-server-5.1.73-8.el6_8.x86_64--> Processing Dependency: libmysqlclient.so.16()(64bit) for package: mysql-server-5.1.73-8.el6_8.x86_64--> Running transaction check---> Package mysql.x86_64 0:5.1.73-8.el6_8 will be installed---> Package mysql-libs.x86_64 0:5.1.73-8.el6_8 will be installed---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be installed---> Package perl-DBI.x86_64 0:1.609-4.el6 will be installed--> Finished Dependency ResolutionDependencies Resolved================================================================================================================================================================================================================= PackageArch           VersionRepository         Size=================================================================================================================================================================================================================Installing: mysql-server           x86_64           5.1.73-8.el6_8           base           8.6 MInstalling for dependencies: mysql x86_64           5.1.73-8.el6_8           base           895 k mysql-libsx86_64           5.1.73-8.el6_8           base           1.2 M perl-DBD-MySQL           x86_64           4.013-3.el6           base           134 k perl-DBIx86_64           1.609-4.el6           base           705 kTransaction Summary=================================================================================================================================================================================================================Install  5 Package(s)Total download size: 12 MInstalled size: 33 MIs this ok [y/N]:6、选择y继续安装Is this ok [y/N]: yDownloading Packages:(1/5): mysql-5.1.73-8.el6_8.x86_64.rpm | 895 kB  00:00  (2/5): mysql-libs-5.1.73-8.el6_8.x86_64.rpm| 1.2 MB  00:00  (3/5): mysql-server-5.1.73-8.el6_8.x86_64.rpm| 8.6 MB  00:02  (4/5): perl-DBD-MySQL-4.013-3.el6.x86_64.rpm| 134 kB  00:00  (5/5): perl-DBI-1.609-4.el6.x86_64.rpm | 705 kB  00:00  -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Total       2.2 MB/s | 12 MB  00:05  Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning Transaction Installing : mysql-libs-5.1.73-8.el6_8.x86_64    1/5  Installing : perl-DBI-1.609-4.el6.x86_64     2/5  Installing : perl-DBD-MySQL-4.013-3.el6.x86_64    3/5  Installing : mysql-5.1.73-8.el6_8.x86_64     4/5  Installing : mysql-server-5.1.73-8.el6_8.x86_64   5/5  Verifying : perl-DBD-MySQL-4.013-3.el6.x86_64    1/5  Verifying : mysql-libs-5.1.73-8.el6_8.x86_64    2/5  Verifying : mysql-server-5.1.73-8.el6_8.x86_64   3/5  Verifying : mysql-5.1.73-8.el6_8.x86_64     4/5  Verifying : perl-DBI-1.609-4.el6.x86_64     5/5 Installed: mysql-server.x86_64 0:5.1.73-8.el6_8       Dependency Installed: mysql.x86_64 0:5.1.73-8.el6_8     mysql-libs.x86_64 0:5.1.73-8.el6_8     perl-DBD-MySQL.x86_64 0:4.013-3.el6     perl-DBI.x86_64 0:1.609-4.el6     Complete!

7、启动mysql服务

[root@cdh1 zjl]# service mysqld startInitializing MySQL database: Installing MySQL system tables...OKFilling help tables...OKTo start mysqld at boot time you have to copysupport-files/mysql.server to the right place for your systemPLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !To do so, start the server, then issue the following commands:/usr/bin/mysqladmin -u root password 'new-password'/usr/bin/mysqladmin -u root -h cdh1.zjl.com password 'new-password'Alternatively you can run:/usr/bin/mysql_secure_installationwhich will also give you the option of removing the testdatabases and anonymous user created by default. This isstrongly recommended for production servers.See the manual for more instructions.You can start the MySQL daemon with:cd /usr ; /usr/bin/mysqld_safe &You can test the MySQL daemon with mysql-test-run.plcd /usr/mysql-test ; perl mysql-test-run.plPlease report any problems with the /usr/bin/mysqlbug script!   [ OK ]Starting mysqld:           [ OK ]

8、连接一下试一下,直接mysql然后\q关闭连接

[root@cdh1 zjl]# mysqlWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.1.73 Source distributionCopyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> \qBye

9、设置mysql开机启动

[root@cdh1 zjl]# chkconfig mysqld on

10、开启3306端口,并保存

[root@cdh1 zjl]# /sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT[root@cdh1 zjl]# /etc/rc.d/init.d/iptables save

11、连接mysql设置密码

[root@cdh1 zjl]# mysqlWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 3Server version: 5.1.73 Source distributionCopyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.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 namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> update user set password=password('123') where user='root';Query OK, 3 rows affected (0.02 sec)Rows matched: 3 Changed: 3 Warnings: 0mysql> flush privileges;Query OK, 0 rows affected (0.02 sec)mysql> \qBye

12、重启mysql服务

[root@cdh1 zjl]# service mysqld restartStopping mysqld:           [ OK ]Starting mysqld:           [ OK ]

以上所述是小编给大家介绍的centos 6.9安装mysql的详细教程,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对站的支持!


  • 上一条:
    Centos7使用yum安装MySQL及实现远程连接的方法
    下一条:
    CentOS 6.6 源码编译安装MySQL 5.7.18教程详解
  • 昵称:

    邮箱:

    0条评论 (评论内容有缓存机制,请悉知!)
    最新最热
    • 分类目录
    • 人生(杂谈)
    • 技术
    • linux
    • Java
    • php
    • 框架(架构)
    • 前端
    • ThinkPHP
    • 数据库
    • 微信(小程序)
    • Laravel
    • Redis
    • Docker
    • Go
    • swoole
    • Windows
    • Python
    • 苹果(mac/ios)
    • 相关文章
    • 在Linux系统中使用Iptables实现流量转发功能流程步骤(0个评论)
    • vim学习笔记-入门级需要了解的一些快捷键(0个评论)
    • 在centos7系统中实现分区并格式化挂载一块硬盘到/data目录流程步骤(0个评论)
    • 在Linux系统种查看某一个进程所占用的内存命令(0个评论)
    • Linux中grep命令中的10种高级用法浅析(0个评论)
    • 近期文章
    • 在go语言中使用api.geonames.org接口实现根据国际邮政编码获取地址信息功能(1个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf分页文件功能(0个评论)
    • gmail发邮件报错:534 5.7.9 Application-specific password required...解决方案(0个评论)
    • 欧盟关于强迫劳动的规定的官方举报渠道及官方举报网站(0个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf文件功能(0个评论)
    • Laravel从Accel获得5700万美元A轮融资(0个评论)
    • 在go + gin中gorm实现指定搜索/区间搜索分页列表功能接口实例(0个评论)
    • 在go语言中实现IP/CIDR的ip和netmask互转及IP段形式互转及ip是否存在IP/CIDR(0个评论)
    • PHP 8.4 Alpha 1现已发布!(0个评论)
    • Laravel 11.15版本发布 - Eloquent Builder中添加的泛型(0个评论)
    • 近期评论
    • 122 在

      学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..
    • 123 在

      Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..
    • 原梓番博客 在

      在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..
    • 博主 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..
    • 1111 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
    • 2016-11
    • 2017-07
    • 2017-10
    • 2017-11
    • 2018-01
    • 2018-02
    • 2020-03
    • 2020-04
    • 2020-05
    • 2020-06
    • 2021-02
    • 2021-03
    • 2021-04
    • 2021-06
    • 2021-07
    • 2021-08
    • 2021-09
    • 2021-10
    • 2021-11
    • 2021-12
    • 2022-01
    • 2022-03
    • 2022-04
    • 2022-08
    • 2022-11
    • 2022-12
    • 2023-01
    • 2023-02
    • 2023-03
    • 2023-06
    • 2023-07
    • 2023-10
    • 2023-12
    • 2024-01
    • 2024-04
    Top

    Copyright·© 2019 侯体宗版权所有· 粤ICP备20027696号 PHP交流群

    侯体宗的博客