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. 创建Django项目(五)——URL配置和视图

    2013-08-07 20:02:10|          1.新建blog的URL文件        在blog目录下新建文件"urls.py" : # -*- coding: ...

  2. Ubuntu 16.04硬盘有坏道,开机显示blk_update_request:I/0 error

    可以尝试以下方式解决: 1.检查坏道(效果明显,但是比较慢,检查出来并没有什么用,只是知道有坏块) sudo badblocks -s -v -o /root/bb.log /dev/sda1 2.快 ...

  3. 奥多朗WIFI 插座

    https://aoduolang.tmall.com/category-1089563810.htm?spm=a1z10.1-b.w11212542-12917613245.12.tTWFSc&am ...

  4. restful接口就是url嘛,通过http请求发起访问。那接口进行监控,就可以监控这个restful url嘛

    EasyAPI接口管理系统 专注API接口监控,让您的API接口更稳定,与APP更紧密 + 购买监控服务 接口性能分析 分析App对应的API接口请求性能,包含HTTP响应时间.吞吐率.HTTP错误率 ...

  5. Python学习系列之文件操作

    Pyhton文件打开方式 with= open('文件路径','打开模式') as f:#PS:python3提供了with语句来帮我们自动调用close方法,所以说无论打开文件是否出错都能自动正确的 ...

  6. git fetch 和 git pull 的差别

    Git中从远程的分支获取最新的版本号到本地有这样2个命令: 1. git fetch:相当于是从远程获取最新版本号到本地,不会自己主动merge git fetch origin master git ...

  7. oracle导入命令,记录一下 数据库日志太大,清理日志文件

    oracle导入命令,记录一下 工作中用到了,这个命令,记录一下,前提要安装imp.exe imp PECARD_HN/PECARD_HN@127.0.0.1:1521/orcl file=E:\wo ...

  8. _DataStructure_C_Impl:图的遍历

    #include<stdio.h> #include<stdlib.h> #include<string.h> //图的邻接表类型定义 typedef char V ...

  9. 2016/1/22 3,将id为005的对象从集合中移除

    package shuzu; public class Emp { private String id; private String name; public Emp(String id, Stri ...

  10. linux switch_root

    1 命令格式 switch_root newroot init 跳转到另外一个文件系统,并且把newroot作为新的mount tree,并且执行init程序. 2 特殊要求 newroot必须是一个 ...