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

[root@cdh1 zjl]# yum list installed mysql*
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.zju.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Installed Packages
MySQL-python.x86_64 1.2.-0.3.c1..el6 @base
mysql-libs.x86_64 5.1.-.el6_8 @anaconda-CentOS-.x86_64/6.9

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

[root@cdh1 zjl]# yum remove MySQL-python.x86_64 mysql-libs.x86_64
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package MySQL-python.x86_64 :1.2.-0.3.c1..el6 will be erased
--> Processing Dependency: MySQL-python for package: cloudera-manager-agent-5.11.-.cm5111.p0..el6.x86_64
---> Package mysql-libs.x86_64 :5.1.-.el6_8 will be erased
--> Processing Dependency: libmysqlclient.so.()(64bit) for package: :postfix-2.6.-.el6.x86_64
--> Processing Dependency: libmysqlclient.so.(libmysqlclient_16)(64bit) for package: :postfix-2.6.-.el6.x86_64
--> Processing Dependency: mysql-libs for package: :postfix-2.6.-.el6.x86_64
--> Running transaction check
---> Package cloudera-manager-agent.x86_64 :5.11.-.cm5111.p0..el6 will be erased
---> Package postfix.x86_64 :2.6.-.el6 will be erased
--> Processing Dependency: /usr/sbin/sendmail for package: redhat-lsb-core-4.0-.el6.centos.x86_64
--> Processing Dependency: /usr/sbin/sendmail for package: cronie-1.4.-.el6_8..x86_64
--> Running transaction check
---> Package cronie.x86_64 :1.4.-.el6_8. will be erased
--> Processing Dependency: cronie = 1.4.-.el6_8. for package: cronie-anacron-1.4.-.el6_8..x86_64
---> Package redhat-lsb-core.x86_64 :4.0-.el6.centos will be erased
--> Processing Dependency: redhat-lsb-core(x86-) = 4.0 for package: redhat-lsb-printing-4.0-.el6.centos.x86_64
--> Processing Dependency: redhat-lsb-core(x86-) = 4.0-.el6.centos for package: redhat-lsb-4.0-.el6.centos.x86_64
--> Processing Dependency: redhat-lsb-core(x86-) = 4.0 for package: redhat-lsb-graphics-4.0-.el6.centos.x86_64
--> Running transaction check
---> Package cronie-anacron.x86_64 :1.4.-.el6_8. will be erased
---> Package redhat-lsb.x86_64 :4.0-.el6.centos will be erased
--> Processing Dependency: redhat-lsb(x86-) = 4.0-.el6.centos for package: redhat-lsb-compat-4.0-.el6.centos.x86_64
---> Package redhat-lsb-graphics.x86_64 :4.0-.el6.centos will be erased
---> Package redhat-lsb-printing.x86_64 :4.0-.el6.centos will be erased
--> Running transaction check
---> Package redhat-lsb-compat.x86_64 :4.0-.el6.centos will be erased
--> Processing Dependency: /etc/cron.d for package: crontabs-1.10-.el6.noarch
--> Processing Dependency: /etc/cron.d for package: sysstat-9.0.-.el6.x86_64
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package crontabs.noarch :1.10-.el6 will be erased
---> Package sysstat.x86_64 :9.0.-.el6 will be erased
--> Finished Dependency Resolution Dependencies Resolved ====================================================================
Package Arch Version Repository
Size
====================================================================
Removing:
MySQL-python x86_64 1.2.-0.3.c1..el6 @base k
mysql-libs x86_64 5.1.-.el6_8 @anaconda-CentOS-.x86_64/6.9
4.0 M
Removing for dependencies:
cloudera-manager-agent x86_64 5.11.-.cm5111.p0..el6 @/cloudera-manager-agent-5.11.-.cm5111.p0..el6.x86_64
M
cronie x86_64 1.4.-.el6_8. @anaconda-CentOS-.x86_64/6.9
k
cronie-anacron x86_64 1.4.-.el6_8. @anaconda-CentOS-.x86_64/6.9
k
crontabs noarch 1.10-.el6 @anaconda-CentOS-.x86_64/6.9
2.4 k
postfix x86_64 :2.6.-.el6 @anaconda-CentOS-.x86_64/6.9
9.7 M
redhat-lsb x86_64 4.0-.el6.centos @anaconda-CentOS-.x86_64/6.9
0.0
redhat-lsb-compat x86_64 4.0-.el6.centos @anaconda-CentOS-.x86_64/6.9
0.0
redhat-lsb-core x86_64 4.0-.el6.centos @anaconda-CentOS-.x86_64/6.9
k
redhat-lsb-graphics x86_64 4.0-.el6.centos @anaconda-CentOS-.x86_64/6.9
0.0
redhat-lsb-printing x86_64 4.0-.el6.centos @anaconda-CentOS-.x86_64/6.9
0.0
sysstat x86_64 9.0.-.el6 @anaconda-CentOS-.x86_64/6.9
k Transaction Summary
====================================================================
Remove Package(s) Installed size: M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Erasing : redhat-lsb-compat-4.0-.el6.centos.x86_64 /
Erasing : redhat-lsb-4.0-.el6.centos.x86_64 /
Erasing : cloudera-manager-agent-5.11.-.cm5111.p0.. /
warning: /etc/cloudera-scm-agent/config.ini saved as /etc/cloudera-scm-agent/config.ini.rpmsave
Erasing : redhat-lsb-graphics-4.0-.el6.centos.x86_64 /
Erasing : redhat-lsb-printing-4.0-.el6.centos.x86_64 /
Erasing : redhat-lsb-core-4.0-.el6.centos.x86_64 /
/var/tmp/rpm-tmp.jLbJUk: line : lsb_release: command not found
Erasing : MySQL-python-1.2.-0.3.c1..el6.x86_64 /
Erasing : sysstat-9.0.-.el6.x86_64 /
Erasing : crontabs-1.10-.el6.noarch /
Erasing : cronie-anacron-1.4.-.el6_8..x86_64 /
Erasing : cronie-1.4.-.el6_8..x86_64 /
Erasing : :postfix-2.6.-.el6.x86_64 /
Erasing : mysql-libs-5.1.-.el6_8.x86_64 /
Verifying : redhat-lsb-printing-4.0-.el6.centos.x86_64 /
Verifying : cronie-anacron-1.4.-.el6_8..x86_64 /
Verifying : cronie-1.4.-.el6_8..x86_64 /
Verifying : :postfix-2.6.-.el6.x86_64 /
Verifying : redhat-lsb-4.0-.el6.centos.x86_64 /
Verifying : redhat-lsb-core-4.0-.el6.centos.x86_64 /
Verifying : cloudera-manager-agent-5.11.-.cm5111.p0.. /
Verifying : crontabs-1.10-.el6.noarch /
Verifying : redhat-lsb-compat-4.0-.el6.centos.x86_64 /
Verifying : MySQL-python-1.2.-0.3.c1..el6.x86_64 /
Verifying : redhat-lsb-graphics-4.0-.el6.centos.x86_64 /
Verifying : sysstat-9.0.-.el6.x86_64 /
Verifying : mysql-libs-5.1.-.el6_8.x86_64 / Removed:
MySQL-python.x86_64 :1.2.-0.3.c1..el6
mysql-libs.x86_64 :5.1.-.el6_8 Dependency Removed:
cloudera-manager-agent.x86_64 :5.11.-.cm5111.p0..el6
cronie.x86_64 :1.4.-.el6_8.
cronie-anacron.x86_64 :1.4.-.el6_8.
crontabs.noarch :1.10-.el6
postfix.x86_64 :2.6.-.el6
redhat-lsb.x86_64 :4.0-.el6.centos
redhat-lsb-compat.x86_64 :4.0-.el6.centos
redhat-lsb-core.x86_64 :4.0-.el6.centos
redhat-lsb-graphics.x86_64 :4.0-.el6.centos
redhat-lsb-printing.x86_64 :4.0-.el6.centos
sysstat.x86_64 :9.0.-.el6 Complete!

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

[root@cdh1 zjl]# whereis mysql
mysql:

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

[root@cdh1 zjl]# yum list mysql*
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.zju.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Available Packages
MySQL-python.x86_64 1.2.-0.3.c1..el6 base
mysql.x86_64 5.1.-.el6_8 base
mysql-bench.x86_64 5.1.-.el6_8 base
mysql-connector-java.noarch :5.1.-.el6 base
mysql-connector-odbc.x86_64 5.1.5r1144-.el6 base
mysql-devel.i686 5.1.-.el6_8 base
mysql-devel.x86_64 5.1.-.el6_8 base
mysql-embedded.i686 5.1.-.el6_8 base
mysql-embedded.x86_64 5.1.-.el6_8 base
mysql-embedded-devel.i686 5.1.-.el6_8 base
mysql-embedded-devel.x86_64 5.1.-.el6_8 base
mysql-libs.i686 5.1.-.el6_8 base
mysql-libs.x86_64 5.1.-.el6_8 base
mysql-server.x86_64 5.1.-.el6_8 base
mysql-test.x86_64 5.1.-.el6_8 base

5、选择mysql-server来安装

[root@cdh1 zjl]# yum install mysql-server
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: mirrors.zju.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package mysql-server.x86_64 :5.1.-.el6_8 will be installed
--> Processing Dependency: mysql = 5.1.-.el6_8 for package: mysql-server-5.1.-.el6_8.x86_64
--> Processing Dependency: perl-DBI for package: mysql-server-5.1.-.el6_8.x86_64
--> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1.-.el6_8.x86_64
--> Processing Dependency: perl(DBI) for package: mysql-server-5.1.-.el6_8.x86_64
--> Processing Dependency: libmysqlclient_r.so.(libmysqlclient_16)(64bit) for package: mysql-server-5.1.-.el6_8.x86_64
--> Processing Dependency: libmysqlclient.so.(libmysqlclient_16)(64bit) for package: mysql-server-5.1.-.el6_8.x86_64
--> Processing Dependency: libmysqlclient_r.so.()(64bit) for package: mysql-server-5.1.-.el6_8.x86_64
--> Processing Dependency: libmysqlclient.so.()(64bit) for package: mysql-server-5.1.-.el6_8.x86_64
--> Running transaction check
---> Package mysql.x86_64 :5.1.-.el6_8 will be installed
---> Package mysql-libs.x86_64 :5.1.-.el6_8 will be installed
---> Package perl-DBD-MySQL.x86_64 :4.013-.el6 will be installed
---> Package perl-DBI.x86_64 :1.609-.el6 will be installed
--> Finished Dependency Resolution Dependencies Resolved =================================================================================================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================================================================================================
Installing:
mysql-server x86_64 5.1.-.el6_8 base 8.6 M
Installing for dependencies:
mysql x86_64 5.1.-.el6_8 base k
mysql-libs x86_64 5.1.-.el6_8 base 1.2 M
perl-DBD-MySQL x86_64 4.013-.el6 base k
perl-DBI x86_64 1.609-.el6 base k Transaction Summary
=================================================================================================================================================================================================================
Install Package(s) Total download size: M
Installed size: M
Is this ok [y/N]:

6、选择y继续安装

Is this ok [y/N]: y
Downloading Packages:
(/): mysql-5.1.-.el6_8.x86_64.rpm | kB :
(/): mysql-libs-5.1.-.el6_8.x86_64.rpm | 1.2 MB :
(/): mysql-server-5.1.-.el6_8.x86_64.rpm | 8.6 MB :
(/): perl-DBD-MySQL-4.013-.el6.x86_64.rpm | kB :
(/): perl-DBI-1.609-.el6.x86_64.rpm | kB :
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 2.2 MB/s | MB :
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : mysql-libs-5.1.-.el6_8.x86_64 /
Installing : perl-DBI-1.609-.el6.x86_64 /
Installing : perl-DBD-MySQL-4.013-.el6.x86_64 /
Installing : mysql-5.1.-.el6_8.x86_64 /
Installing : mysql-server-5.1.-.el6_8.x86_64 /
Verifying : perl-DBD-MySQL-4.013-.el6.x86_64 /
Verifying : mysql-libs-5.1.-.el6_8.x86_64 /
Verifying : mysql-server-5.1.-.el6_8.x86_64 /
Verifying : mysql-5.1.-.el6_8.x86_64 /
Verifying : perl-DBI-1.609-.el6.x86_64 / Installed:
mysql-server.x86_64 :5.1.-.el6_8 Dependency Installed:
mysql.x86_64 :5.1.-.el6_8 mysql-libs.x86_64 :5.1.-.el6_8 perl-DBD-MySQL.x86_64 :4.013-.el6 perl-DBI.x86_64 :1.609-.el6 Complete!

7、启动mysql服务

[root@cdh1 zjl]# service mysqld start
Initializing MySQL database: Installing MySQL system tables...
OK
Filling help tables...
OK To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system PLEASE 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_installation which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly 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.pl
cd /usr/mysql-test ; perl mysql-test-run.pl Please report any problems with the /usr/bin/mysqlbug script! [ OK ]
Starting mysqld: [ OK ]

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

[root@cdh1 zjl]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.1. Source distribution Copyright (c) , , 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> \q
Bye

9、设置mysql开机启动

[root@cdh1 zjl]# chkconfig mysqld on

10、开启3306端口,并保存

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

11、连接mysql设置密码

[root@cdh1 zjl]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.1. Source distribution Copyright (c) , , 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('') where user='root';
Query OK, rows affected (0.02 sec)
Rows matched: Changed: Warnings: mysql> flush privileges;
Query OK, rows affected (0.02 sec) mysql> \q
Bye

12、重启mysql服务

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

centos 6.9安装mysql的更多相关文章

  1. centos上如何安装mysql

    centos可以使用yum安装mysql 但是版本很低,且不灵活. 本文将介绍如何使用安装包安装mysql http://dev.mysql.com/downloads/mysql/ 下载mysql ...

  2. CentOS 7离线安装MySQL 5.7

    系列文章首发平台为果冻想个人博客.果冻想,是一个原创技术文章分享网站.在这里果冻会分享他的技术心得,技术得失,技术人生.我在果冻想等待你,也希望你能和我分享你的技术得与失,期待. 前言 网上已经有那么 ...

  3. centos 7 中安装 mysql 5.7

    centos 7 中安装 mysql 5.7 环境说明: 查看centos的版本:cat /etc/redhat-release 安装和配置步骤: 下载 mysql 源安装包: sudo curl - ...

  4. CentOS 6.5 安装MySQL数据库

    CentOS 6.5 安装MySQL数据库 [root@seeker~]# yum -y install mysql-server //安装命令 [root@seeker~]# service mys ...

  5. CentOS 7.0yum安装MySQL

    CentOS 7.0yum安装MySQL 1.下载mysql的repo源 $ wget http://repo.mysql.com/mysql-community-release-el7-5.noar ...

  6. CentOS 6.9安装MySQL 5.6 (使用yum安装)

    CentOS 6.9安装MySQL 5.6 (使用yum安装) 移除CentOS默认的mysql-libs [root@test01 srv]# whereis mysqlmysql: /usr/li ...

  7. CentOS 7 下安装 MySQL 5.7

    从 CentOS 7 系统开始,MariaDB 成为 yum 源中默认的数据库安装包.在 CentOS 7 及以上的系统中使用 yum 安装 MySQL 包将无法使用 MySQL.您可以选择使用完全兼 ...

  8. 20190526 - CentOS 7 中 安装 MySQL 8 并授权 root 远程访问

    1. CentOS 7 中 安装 MySQL 8 CentOS 7 中内置 MariaDB 建议升级一下用,性能好很多.但如果一定要用 MySQL 8,就得自己装. 坦白的说,Oracle 升级 My ...

  9. centos 6.10 安装mysql 5.7.27 出现缺少libnuma.so.1的问题

    centos 6.10安装mysql 5.7.27出现以下报错: [root@localhost /]# /usr/local/mysql/app/mysql/bin/mysqld --default ...

  10. centOS 7 离线安装 MySQL 5.6 完美安装

    centOS 7 离线安装 MySQL 5.6 centOS 7 离线安装 MySQL 5.6 准备环境 1.离线 centOS 7(此处为 centOS 7 最小安装) 2.nginx 安装文件 ( ...

随机推荐

  1. Mysql千万级数据删除实操-企业案例

    某天,在生产环节中,发现一个定时任务表,由于每次服务区查询这个表就会造成慢查询,给mysql服务器带来不少压力,经过分析,该表中绝对部分数据是垃圾数据 需要删除,约1050万行,由于缺乏处理大数据的额 ...

  2. Python2.7-decimal

    decimal 模块,提供了对小数精确的计算,内置的 float 类型是以二进制的浮点数保存的,是不准确的,小数点后会有很多奇怪的数字,虽然在一般情况下计算是没问题的,因为近似相等,小数点后十几位才会 ...

  3. jqgrid 对编辑行填写的内容做格式验证

    有时,我们需要在基于jqgrid表格编辑行的单元格做规范验证.jqgrid提供有支持,通过设置字段的editrules属性来约束格式. 约束方式: 1.内置的约束参数 (required: true, ...

  4. x window的奥秘

    阅读目录 了解自己机器上的 X Window 理解 display 和虚拟控制台 远程连接 X Server 理解 lightdm 和 X Window 桌面环境的启动过程 搞定 xauth X Se ...

  5. Codeforces Educational round 58

    Ediv2 58 随手AK.jpg D 裸的虚树,在这里就不写了 E 傻逼贪心?这个题过的比$B$都多.jpg #include <cstdio> #include <algorit ...

  6. 20155226《网络攻防》 Exp3 免杀原理与实践

    20155226<网络攻防> Exp3 免杀原理与实践 实验过程 1. msfvenom直接生成meterpreter可执行文件 直接将上周做实验时用msf生成的后门文件放在virscan ...

  7. 20155334 网络对抗PC平台逆向破解(二)

    注入Shellcode并运行攻击 shellcode就是一段机器指令(code) 通常这段机器指令的目的是为获取一个交互式的shell(像linux的shell或类似windows下的cmd.exe) ...

  8. 在java代码中执行js脚本,实现计算出字符串“(1+2)*(1+3)”的结果

            今天在公司项目中,发现一个计算运费的妙招.由于运费规则各种各样,因此写一个公式存到数据库.下次需要计算运费时,直接取出这个公式,把公式的未知变量给替换掉,然后计算出结果就是ok了. 一 ...

  9. FIFO IP核

    转载: 说白了,IP核就是别人做好了的硬件模块,提供完整的用户接口和说明文档,更复杂的还有示例工程,你只要能用好这个IP核,设计已经完成一半了.说起来容易,从冗长的英文文档和网上各个非标准教程中汲取所 ...

  10. ajax传递数组给controller的实现方法和坑

    这里是前端向后端传递一个数组的方式,参考下面这个示例: (主要是将前端的数组,用 JSON.stringify() 方法json化一下,然后后端springmvc接收到以后,使用 JSONArray  ...