Linux环境下卸载原有MySQL5.1数据库,并重新安装MySQL数据库的示例记录。

一、卸载MySQL

查看主机中是否安装了MySQL数据库:

[root@RD-viPORTAL-1 ~]# rpm -qa|grep mysql
mysql-5.1.73-5.el6_6.x86_64
mysql-devel-5.1.73-5.el6_6.x86_64
mysql-libs-5.1.73-5.el6_6.x86_64

然后通过rpm -e命令进行软件包的卸载;

[root@RD-viPORTAL-1 ~]# rpm -e mysql-5.1.73-5.el6_6.x86_64
error: Failed dependencies:
mysql = 5.1.73-5.el6_6 is needed by (installed) mysql-devel-5.1.73-5.el6_6.x86_64

发现软件包有依赖关系,百度发现可以使用“--nodeps”参数进行卸载。

[root@RD-viPORTAL-1 ~]# rpm -e mysql-5.1.73-5.el6_6.x86_64 --nodeps
[root@RD-viPORTAL-1 ~]# rpm -e mysql-devel-5.1.73-5.el6_6.x86_64 --nodeps
[root@RD-viPORTAL-1 ~]# rpm -e mysql-libs-5.1.73-5.el6_6.x86_64 --nodeps

再次查询MySQL的软件包,发现已经没有相关的rpm包了。

[root@RD-viPORTAL-1 ~]# rpm -qa|grep mysql
[root@RD-viPORTAL-1 ~]#

二、安装MySQL

安装MySQL一般需要如下rpm包。

[root@RD-viPORTAL-1 mysql]# ll
总用量 11788
-rw-r--r-- 1 root root 915088 2月 15 05:27 mysql-5.1.73-5.el6_6.x86_64.rpm
-rw-r--r-- 1 root root 131900 2月 15 05:27 mysql-devel-5.1.73-5.el6_6.x86_64.rpm
-rw-r--r-- 1 root root 1282760 2月 15 05:27 mysql-libs-5.1.73-5.el6_6.x86_64.rpm
-rw-r--r-- 1 root root 9033560 2月 15 05:27 mysql-server-5.1.73-5.el6_6.x86_64.rpm
-rw-r--r-- 1 root root 136464 2月 15 05:32 perl-DBD-MySQL-4.013-3.el6.x86_64.rpm

安装顺序:

perl-DBD-MySQL-4.013-3.el6.x86_64.rpm
mysql-libs-5.1.73-5.el6_6.x86_64.rpm
mysql-5.1.73-5.el6_6.x86_64.rpm
mysql-server-5.1.73-5.el6_6.x86_64.rpm
mysql-devel-5.1.73-5.el6_6.x86_64.rpm

安装过程:

使用“rpm -ivh”命令安装rpm包。

[root@RD-viPORTAL-1 mysql]# rpm -ivh mysql-libs-5.1.73-5.el6_6.x86_64.rpm
Preparing...                ########################################### [100%]
   1:mysql-libs             ########################################### [100%]

[root@RD-viPORTAL-1 mysql]# rpm -ivh mysql-5.1.73-5.el6_6.x86_64.rpm
Preparing... ########################################### [100%]
1:mysql ########################################### [100%]
[root@RD-viPORTAL-1 mysql]#
[root@RD-viPORTAL-1 mysql]# rpm -ivh mysql-server-5.1.73-5.el6_6.x86_64.rpm
Preparing... ########################################### [100%]
1:mysql-server ########################################### [100%]
[root@RD-viPORTAL-1 mysql]#
[root@RD-viPORTAL-1 mysql]# rpm -ivh mysql-devel-5.1.73-5.el6_6.x86_64.rpm
Preparing... ########################################### [100%]
1:mysql-devel ########################################### [100%]

使用service命令查看MySQL安装状态:

[root@RD-viPORTAL-1 mysql]# service mysqld status
mysqld 已停

使用service命令启动MySQL并初始化:

[root@RD-viPORTAL-1 mysql]# service mysqld start
初始化 MySQL 数据库: 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 RD-viPORTAL-1 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! [确定]
正在启动 mysqld: [确定]
[root@RD-viPORTAL-1 mysql]#

查询3306端口确认是否正常启动:

[root@RD-viPORTAL-1 mysql]# netstat -an|grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
unix 2 [ ACC ] STREAM LISTENING 19314 /tmp/orbit-gdm/linc-c5a-0-4d33062e40154
unix 3 [ ] STREAM CONNECTED 19323 /tmp/orbit-gdm/linc-c5a-0-4d33062e40154
unix 3 [ ] STREAM CONNECTED 19320 /tmp/orbit-gdm/linc-c5a-0-4d33062e40154

MySQL默认配置路径:

[root@RD-viPORTAL-1 mysql]# cd /var/lib/mysql/
[root@RD-viPORTAL-1 mysql]# ll
总用量 20488
-rw-rw---- 1 mysql mysql 10485760 2月 15 05:52 ibdata1
-rw-rw---- 1 mysql mysql 5242880 2月 15 05:52 ib_logfile0
-rw-rw---- 1 mysql mysql 5242880 2月 15 05:52 ib_logfile1
drwx------ 2 mysql mysql 4096 2月 15 05:52 mysql
srwxrwxrwx 1 mysql mysql 0 2月 15 05:52 mysql.sock
drwx------ 2 mysql mysql 4096 2月 15 05:52 test

三、配置MySQL

设置root用户密码

默认情况下MySQL是不需要登录密码的,为安全起见,设置MySQL密码。

[root@RD-viPORTAL-1 mysql]# mysqladmin -u root password "passw0rd"

此时直接登录显示访问拒绝:

[root@RD-viPORTAL-1 mysql]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

使用如下命令登录MySQL:

[root@RD-viPORTAL-1 mysql]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, 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> select * from user;
ERROR 1046 (3D000): No database selected
mysql> exit
Bye

授权root用户可以远程访问:

[root@RD-viPORTAL-1 mysql]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, 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> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec) mysql> exit
Bye
[root@RD-viPORTAL-1 mysql]#

Linux环境下卸载、安装及配置MySQL5.1的更多相关文章

  1. LINUX环境下SVN安装与配置(利用钩子同步开发环境与测试环境)

    安装采用YUM一键安装: 1.环境Centos 6.6 2.安装svnyum -y install subversion 3.配置 建立版本库目录mkdir /www/svndata svnserve ...

  2. Linux环境下mysql安装并配置远程访问

    环境:centOS 1.下载mysql安装文件 [root@localhost ~]# wget http://dev.mysql.com/get/mysql-community-release-el ...

  3. linux环境下jdk安装以及配置

    linux 环境安装jdk和配置环境变量: (此处以root用户安装,此方式安装一台虚拟机装一个jdk即可,所有普通用户可以共用) 1.下载安装jdk 链接: https://pan.baidu.co ...

  4. Windows和Linux环境下Memcached安装与配置(转)

    一.memcached安装配置 windows平台安装 1.memcached-1.2.6-win32-bin.zip下载地址: http://code.jellycan.com/memcached/ ...

  5. Linux 环境下java安装及配置

    操作系统环境: Red Hat Enterpriser  Linux 6.5 jdk版本:  jdk1.8.0_144 1 从官网下载Linux操作系统对应的jdk版本文件 2 安装jdk 3 安装完 ...

  6. Linux 环境下jmeter 安装和配置

    1. 下载和安装JDK vim /etc/profile export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_92 export JRE_HOME=$JAVA_HOME/jr ...

  7. Linux/CentOS环境下如何安装和配置PhantomJS工作环境

    PhantomJS 是一个基于WebKit的服务器端 JavaScript API.它全面支持web而不需浏览器支持,其快速,原生支持各种Web标准: DOM 处理, CSS 选择器, JSON, C ...

  8. 【VNC】Linux环境VNC服务安装、配置与使用

     [VNC]Linux环境VNC服务安装.配置与使用 2009-06-25 15:55:31 分类: Linux   前言:作为一名DBA,在创建Oracle数据库的过程中一般要使用dbca和netc ...

  9. 全世界最详细的图形化VMware中linux环境下oracle安装(一)【weber出品必属精品】

    安装流程:前期准备工作--->安装ORACLE软件--->安装升级补丁--->安装odbc创建数据库--->安装监听器--->安装EM <前期准备工作> 安装 ...

随机推荐

  1. HDU 1754 I Hate It (Splay 区间操作)

    题目大意 维护一个序列,支持两种操作 操作一:将第x个元素的值修改为y 操作二:询问区间[x,y]内的元素的最大值 解题分析 splay的区间操作,事先加入两个编号最小和最大的点防止操作越界. 具体的 ...

  2. ZOJ 2770_Burn the Linked Camp

    题意: 给定每个兵营的最大容量,以及第i到第j个兵营至少有多少个士兵,问所有兵营一共至少有多少个士兵? 分析: 差分约束系统,注意 第i到第j至少有k个 第i到第j最多有最大容量之和个 每个兵营至少有 ...

  3. 远程调试 Android 设备使用入门(谷歌翻译版)

    移动前端调试方案(Android + Chrome 实现远程调试) 目录 要求 第 1 步:发现您的 Android 设备 第 2 步:从您的开发计算机调试 Android 设备上的内容. 更多操作: ...

  4. cogs——1364. 聚会

    1364. 聚会 ★   输入文件:partyb.in   输出文件:partyb.out   简单对比时间限制:1 s   内存限制:128 MB [问题描述] 小S想要从某地出发去同学k的家中参加 ...

  5. 洛谷—— P3370 【模板】字符串哈希

    P3370 [模板]字符串哈希 题目描述 如题,给定N个字符串(第i个字符串长度为Mi,字符串内包含数字.大小写字母,大小写敏感),请求出N个字符串中共有多少个不同的字符串. 友情提醒:如果真的想好好 ...

  6. 携程Apollo(阿波罗)配置中心把现有项目的配置文件迁移到Apollo

    说明: 1.这个示例应该算是一个静态迁移,也就是说配置更新后要重启应用才能体现更新,目的是展示现有配置的如何迁移. 2.如果要实现更新配置后动态去更新而不重启应用的操作,比如ZK地址和数据库地址这些, ...

  7. dataTables 添加行内操作按钮

    在上一篇博客中我们提到了用dataTables 做一个分页表格.今天进一步进阶,做一个行内带操作按钮的表格.效果如图. 记得最基础的实现方式是,我们要在js 中拼接字符串,嵌入一个带按钮的语句.但是现 ...

  8. 【c++】【转】C++ sizeof 使用规则及陷阱分析

    http://www.cnblogs.com/chio/archive/2007/06/11/778934.html sizeof不是函数,更像一个特殊的宏,它是在编译阶段求值得.sizeof作用范围 ...

  9. OJ-online judegement

    OJ-online judegement https://baike.baidu.com/item/OJ/8129019?fr=aladdin

  10. [Unity3D]Unity3D游戏开发之从Unity3D到Eclipse

    ---------------------------------------------------------------------------------------------------- ...