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. IntentService用于服务中开启子线程的自动关闭

    package com.pingyijinren.test; import android.app.IntentService; import android.content.Intent; impo ...

  2. 洛谷——P1151 子数整数

    P1151 子数整数 题目描述 对于一个五位数a1a2a3a4a5,可将其拆分为三个子数: sub1=a1a2a3 sub2=a2a3a4 sub3=a3a4a5 例如,五位数20207可以拆分成 s ...

  3. Eclipse-Java代码规范和质量检查插件-阿里编码规约

    此工具配套阿里巴巴Java开发手册:http://www.cnblogs.com/EasonJim/p/6436387.html Eclipse安装和使用方法:https://github.com/a ...

  4. TensorFlow-GPU环境配置之一——安装Ubuntu双系统

    本机已经安装过Windows系统,准备安装Ubuntu双系统进行TensorFlow相关工作,需要在windows中将磁盘分出一定空间供Ubuntu使用 1.首先下载Ubuntu17.04版本ISO ...

  5. python 交互模式 方向键乱码问题解决

    python交互模式下通常用向上键来找到之前执行的命令,用左右键移动光标.这很方便.但有的时候这些键在按完后却会出现乱码. 本文只解决CentOS 6.4 下 python2.7.8 的乱码问题. 这 ...

  6. 玩转iOS开发 - 消息推送

    消息推送

  7. [Jest] Automate your migration to Jest using codemods

    Jest is a fantastic testing library, but maybe you've been putting off the switch because migrating ...

  8. Office 如何打印彩色照片能取得较好的效果

    1 如下图所示,随便打开一个照片,点击打印,纸张大小,质量,纸张类型如下所示.   2 这样打印的设置还是不够的,因为"高级光面纸"或者类似的纸张类型,会把色彩浓度调大,相对于普通 ...

  9. redis 事务 及发布于订阅功能

    事务: Redis事务可以一次执行多个命令,事务具有以下特征: 1.隔离操作:事务中的所有命令都会序列化.按顺序地执行,不会被其他命令打扰. 2.原子操作:事务中的命令要么全部被执行,要么全部都不执行 ...

  10. LINQ实现

    public static IEnumerable<TSource> MyWhere<TSource>(     this IEnumerable<TSource> ...