iis服务器助手广告广告
返回顶部
首页 > 资讯 > 数据库 >Mysql 卸载 安装 全过程
  • 159
分享到

Mysql 卸载 安装 全过程

2024-04-02 19:04:59 159人浏览 八月长安
摘要

Mysql一个熟悉的概念,一个全新的知识领域。开始我全方位数据库学习之旅。一切,从安装开始,自己动手每一步。linux在安装的过程中,可以勾选mysql的安装,但是安装的版本是Mysql-5.1.73,版本

Mysql一个熟悉的概念,一个全新的知识领域。开始我全方位数据库学习之旅。

一切,从安装开始,自己动手每一步。


linux在安装的过程中,可以勾选mysql的安装,但是安装的版本是Mysql-5.1.73,版本非常低。必须重新安装,当前最新版本是5.7。但是卸载再安装,明显比空白Linux安装麻烦一点。


下面开始卸载/安装过程。


1. Mysql下载地址

mysql-5.7.22-1.el6.x86_64.rpm-bundle.tar
https://dev.mysql.com/downloads/file/?id=476884

2. 确认OS版本

# more /etc/issue
Centos release 6.7 (Final)
Kernel \r on an \m
# lsb_release -a
LSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description:    CentOS release 6.7 (Final)
Release:        6.7
Codename:       Final

3. 根据OS版本,找到需要下载的Mysql版本,右键“将链接另存为”,即可获得下载地址

Mysql 卸载 安装 全过程

4. 到Linux下,通过wget下载

wget Https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-commUnity-server-5.7.18-1.el6.x86_64.rpm

下面三个rpm包存在依赖关系,也需要下载

# wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-common-5.7.18-1.el6.x86_64.rpm
# wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-client-5.7.18-1.el6.x86_64.rpm
# wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-libs-5.7.18-1.el6.x86_64.rpm

5. 检查查询发现,已经安装Mysql-5.1.73,版本非常低。必须重新安装,当前最新版本是5.7

# rpm -qa | grep mysql
mysql-server-5.1.73-5.el6_6.x86_64
mysql-libs-5.1.73-5.el6_6.x86_64
mysql-5.1.73-5.el6_6.x86_64
mysql-connector-odbc-5.1.5r1144-7.el6.x86_64

6. 准备安装,安装前,就怀疑,会不会覆盖?会不会冲突?安装一下试试,就知道了。

同时安装4个rpm包

# rpm -ivh  mysql-community-server-5.7.18-1.el6.x86_64.rpm mysql-community-client-5.7.18-1.el6.x86_64.rpm  mysql-community-common-5.7.18-1.el6.x86_64.rpm mysql-community-libs-5.7.18-1.el6.x86_64.rpm

7. 果然冲突了

warning: mysql-community-server-5.7.18-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
file /usr/share/mysql/czech/errmsg.sys from install of mysql-community-common-5.7.18-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/danish/errmsg.sys from install of mysql-community-common-5.7.18-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/dutch/errmsg.sys from install of mysql-community-common-5.7.18-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/english/errmsg.sys from install of mysql-community-common-5.7.18-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/estonian/errmsg.sys from install of mysql-community-common-5.7.18-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
......

8. 经过查询,也安装失败了,还是5.1.73版本

# rpm -qa|grep mysql
mysql-server-5.1.73-5.el6_6.x86_64
mysql-libs-5.1.73-5.el6_6.x86_64
mysql-5.1.73-5.el6_6.x86_64
mysql-connector-odbc-5.1.5r1144-7.el6.x86_64

9. 开始卸载原有的5.1.73的Mysql,几种卸载方式,首推YUM方式卸载

# yum remove mysql
# rpm -e mysql  // 普通删除模式 
# rpm -e --nodeps mysql  // 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除

10 .还剩余下面两个包

# rpm -qa|grep mysql
mysql-libs-5.1.73-5.el6_6.x86_64
mysql-connector-odbc-5.1.5r1144-7.el6.x86_64

11. 执行yum localinstall安装,发现需要卸载mysql-libs-5.1.73-5.el6_6.x86_64,通过yun卸载这个包后,可以安装了。

# yum localinstall mysql-community-server-5.7.18-1.el6.x86_64.rpm mysql-community-client-5.7.18-1.el6.x86_64.rpm mysql-community-common-5.7.18-1.el6.x86_64.rpm  mysql-community-libs-5.7.18-
1.el6.x86_64.rpm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Local Package Process
Examining mysql-community-server-5.7.18-1.el6.x86_64.rpm: mysql-community-server-5.7.18-1.el6.x86_64
Marking mysql-community-server-5.7.18-1.el6.x86_64.rpm to be installed
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.cn99.com
* updates: mirrors.163.com
Examining mysql-community-client-5.7.18-1.el6.x86_64.rpm: mysql-community-client-5.7.18-1.el6.x86_64
Marking mysql-community-client-5.7.18-1.el6.x86_64.rpm to be installed
Examining mysql-community-common-5.7.18-1.el6.x86_64.rpm: mysql-community-common-5.7.18-1.el6.x86_64
Marking mysql-community-common-5.7.18-1.el6.x86_64.rpm to be installed
Examining mysql-community-libs-5.7.18-1.el6.x86_64.rpm: mysql-community-libs-5.7.18-1.el6.x86_64
Marking mysql-community-libs-5.7.18-1.el6.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.18-1.el6 will be installed
---> Package mysql-community-common.x86_64 0:5.7.18-1.el6 will be installed
---> Package mysql-community-libs.x86_64 0:5.7.18-1.el6 will be installed
---> Package mysql-community-server.x86_64 0:5.7.18-1.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==================================================================================================================================
Package                         Arch            Version               Repository                                            Size
==================================================================================================================================
Installing:
mysql-community-client          x86_64          5.7.18-1.el6          /mysql-community-client-5.7.18-1.el6.x86_64          100 M
mysql-community-common          x86_64          5.7.18-1.el6          /mysql-community-common-5.7.18-1.el6.x86_64          2.5 M
mysql-community-libs            x86_64          5.7.18-1.el6          /mysql-community-libs-5.7.18-1.el6.x86_64            8.9 M
mysql-community-server          x86_64          5.7.18-1.el6          /mysql-community-server-5.7.18-1.el6.x86_64          769 M
Transaction Summary
==================================================================================================================================
Install       4 Package(s)
Total size: 880 M
Installed size: 880 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : mysql-community-common-5.7.18-1.el6.x86_64                                                                     1/4
Installing : mysql-community-libs-5.7.18-1.el6.x86_64                                                                       2/4
Installing : mysql-community-client-5.7.18-1.el6.x86_64                                                                     3/4
Installing : mysql-community-server-5.7.18-1.el6.x86_64                                                                     4/4
Verifying  : mysql-community-server-5.7.18-1.el6.x86_64                                                                     1/4
Verifying  : mysql-community-libs-5.7.18-1.el6.x86_64                                                                       2/4
Verifying  : mysql-community-common-5.7.18-1.el6.x86_64                                                                     3/4
Verifying  : mysql-community-client-5.7.18-1.el6.x86_64                                                                     4/4
Installed:
mysql-community-client.x86_64 0:5.7.18-1.el6                    mysql-community-common.x86_64 0:5.7.18-1.el6
mysql-community-libs.x86_64 0:5.7.18-1.el6                      mysql-community-server.x86_64 0:5.7.18-1.el6
Complete!

12. 最后检查,已经安装成功

# rpm -qa|grep mysql
mysql-community-client-5.7.18-1.el6.x86_64
mysql-community-libs-5.7.18-1.el6.x86_64
mysql-community-common-5.7.18-1.el6.x86_64
mysql-community-server-5.7.18-1.el6.x86_64

13. 安装完成,但是启动的时候遇到了问题:

# service mysqld restart
Stopping mysqld:                                           [  OK  ]
Initializing MySQL database:  2017-07-11T15:23:50.462866Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-07-11T15:23:50.465315Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2017-07-11T15:23:50.465365Z 0 [ERROR] Aborting
[FAILED]

14. 百度的解决方法(是由于之前老版本的数据库已经占用这个文件夹,需要清空,或者在/etc/my.cnf中重新指定--datadir)

保证 --datadir目录为空。 /usr/local/var/mysql 这个目录


15. 启动成功

# cd /var/lib/mysql
# ls
auto.cnf  ib_buffer_pool  ibdata1  ib_logfile0  ib_logfile1
# rm *
rm: remove regular file `auto.cnf'? y
rm: remove regular file `ib_buffer_pool'? y
rm: remove regular file `ibdata1'? y
rm: remove regular file `ib_logfile0'? y
rm: remove regular file `ib_logfile1'? y

# service mysqld restart

Stopping mysqld:                                           [  OK  ]
Initializing MySQL database:                               [  OK  ]
Installing validate passWord plugin:                       [  OK  ]
Starting mysqld:                                           [  OK  ]

# ps -ef|grep mysql

root      4533     1  0 23:25 pts/0    00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --Socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql
mysql     4727  4533  4 23:25 pts/0    00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
root      4762  3752  0 23:25 pts/0    00:00:00 grep mysql

16. 然而启动的过程中,又遇到一些问题,密码不知道了,重置密码

# mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@test mysql]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

编辑mysql配置文件/etc/my.cnf,在[mysqld]这个条目下加入 skip-grant-tables 保存退出后重启mysql

# vi /etc/my.cnf

[root@test mysql]# service mysqld restart
Stopping mysqld:                                           [  OK  ]
Starting mysqld:                                           [  OK  ]

# mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.18 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| infORMation_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

设置密码,然后删除/etc/my.cnf中的 skip-grant-tables

再次重启mysql

mysql> use mysql;
Database changed

--.给root用户设置新密码: 

5.7版本之前:

mysql> update user set password=password("新密码") where user="root";
Query OK, 1 rows affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0

在5.7版本之后,mysql数据库下已经没有password这个字段了,password字段改成了authentication_string。

update mysql.user set authentication_string=PASSWORD('oracle') where User='root';
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

---退出mysql,重启然后重新登录

# service mysqld restart
Stopping mysqld:                                           [  OK  ]
Starting mysqld:                                           [  OK  ]

# mysql -uroot -poracle

mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.18
Copyright (c) 2000, 2017, 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>




您可能感兴趣的文档:

--结束END--

本文标题: Mysql 卸载 安装 全过程

本文链接: https://www.lsjlt.com/news/38399.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • MySQL下载安装及完美卸载的详细过程
    目录1.MySQL的安装2.MySQL的启动与停止3.客户端连接4.MySQL完美卸载结束语1.MySQL的安装 (1)双击我们去官网下载好的MySQL (2) 一直点下一步,直到...
    99+
    2022-11-13
    mysql安装教程 mysql卸载服务 mysql完全卸载教程
  • 如何完全卸载linux下通过rpm安装的mysql
    卸载linux下通过rpm安装的mysql 1.关闭MySQL服务2.使用 rpm 命令的方式查看已安装的mysql3. 使用rpm -ev 命令移除安装4. 查询是否还存在遗漏文件5. 删除...
    99+
    2023-10-11
    linux mysql 服务器
  • Ubuntu下安装卸载python3.8的过程
    目录一、Python 3.8 安装1.通过 Apt 安装Python3.82.配置 python3.8 为系统默认 python3二、卸载python3.8 1、卸载pyt...
    99+
    2024-04-02
  • 如何卸载mysql教程(完全卸载)
    步骤1:关闭MySQL服务 右击【计算机】,选择【管理】,打开“计算机管理”界面 选择【服务和应用程序】中的【服务】,在右侧找到【mysql】,右键,选择【停止】   步骤2:卸载mysql软件 可以在控制面板中卸载,把mysql相关的全...
    99+
    2023-08-31
    数据库 java 开发语言
  • MySQL的卸载与安装(Linux)
    MySQL 前言1. 卸载MySQL1.1 查询与关闭对应MySQL服务1.2 卸载对应安装包 2. 安装MySQL2.1 配置MySQL官方yum源2.2 开始安装MySQL 前言 在这里演示的卸载与安装MySQL都是...
    99+
    2023-12-23
    mysql linux 数据库
  • MySQL的安装以及卸载
    下载官网 https://www.mysql.com/ 切到下载tab页 找到 MySQL Community Server 或者 MySQL Community (GPL) Downloads --> MySQL Community S...
    99+
    2023-08-25
    mysql 数据库
  • 【MySQL】CentOS7 卸载以及安装 MySQL 详细流程
    一、卸载 MySQL 查看 MySQL 安装版本 mysqladmin --version 通过 rpm 查找 MySQL rpm -qa|grep -i mysql 查看 MySQL 运行状态 s...
    99+
    2023-09-08
    mysql linux 数据库
  • mysql如何通过二进制包安装及卸载
    这篇文章主要为大家展示了“mysql如何通过二进制包安装及卸载”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“mysql如何通过二进制包安装及卸载”这篇文章吧。 ...
    99+
    2024-04-02
  • 如何通过rpm包安装、配置及卸载mysql
    这篇文章主要讲解了“如何通过rpm包安装、配置及卸载mysql”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“如何通过rpm包安装、配置及卸载mysql”吧!以MySQL-server-4.0...
    99+
    2023-06-13
  • Linux下MySQL卸载和安装图文教程
    第一次写博客,做了两年的开发,工作之余给自己找点有意义的事做,分享一下在开发过程当中的一些经验总结,同时也当是自己的笔记吧,有时候有些东西长时间不用自己也记不住,好了,废话就说到这里,接下来讲解Linux环...
    99+
    2024-04-02
  • MySQL 8.0.12的安装与卸载教程详解
    一,MySQL8.0.12版本安装步骤。 1,下载 https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.12-winx64.zip 2,解压 将m...
    99+
    2024-04-02
  • 怎么卸载mysql重新安装
    要卸载 MySQL 并重新安装,可以按照以下步骤操作:1. 停止 MySQL 服务。在终端或命令提示符中输入以下命令:- 对于 Wi...
    99+
    2023-10-09
    mysql
  • 下载安装MySQL过程详解
    目录 一、MySQL下载 1.登入官网下载mysql的安装包 2.下载格式 3.下载完成后为压缩包 4.将 zip 包解压缩 5.在上面图示的文件内,新建 "my.ini" 空文件 6.打开 “my.ini” 文件 二、配置环境变量 1.打...
    99+
    2023-09-01
    mysql 数据库
  • Window下完全卸载MySQL教程
    windows系统( 快捷键win+r )进入命令行输入:net stop mysql 或进入任务管理器直接查找到MySQL服务运行进程 进入控制面板,卸载mysql 进入C:\Program Files (x86),C:\Program ...
    99+
    2023-09-02
    mysql 数据库 java
  • mac卸载mysql教程(按照步骤可完全卸载)
    Mac下卸载mysql的方法:(大部分卸载是因为版本高) 关闭mysql 查看mysql是否启动:ps -ef |grep mysql  2、输入:kill -9 然后回车,关闭mysql。 卸载: 在Mac终端使用下面的命令删除所有my...
    99+
    2023-09-05
    数据库 java sql mysql 前端
  • MongoDB卸载安装的详细安装教程
    目录01 卸载1、 sc stop MongoDB2、 sc delete MongoDB3、 然后再是软件卸载,数据库删除02 MongoDB安装02::01 MongoDB安装1、安装02::02 配置MongDB1...
    99+
    2023-04-14
    mongodb如何卸载 卸载mongodb mongodb的安装配置
  • Centos7上卸载MariaDB数据库并安装mysql的过程是怎样的
    这篇文章给大家介绍Centos7上卸载MariaDB数据库并安装mysql的过程是怎样的,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。(1) 列出所有被安装的rpm package#&...
    99+
    2024-04-02
  • MySql安装、配置、卸载的方法
    小编给大家分享一下MySql安装、配置、卸载的方法,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!一、MYSQL的安装1、打开下载...
    99+
    2024-04-02
  • Linux下MySQL5.7.18 yum方式从卸载到安装的过程
    这篇文章给大家分享的是有关Linux下MySQL5.7.18 yum方式从卸载到安装的过程的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。每一步都参考了不少文章,后面会一一列举出来...
    99+
    2024-04-02
  • win7手动卸载驱动适合不能通过卸载程序进行全面卸载
      大家都   操作步骤:   1.开始-设备和打印机:随便选择一个打印机图标,选择打印机服务器属性;      2.单击打印服务器属性--驱动程序--删除,选择删除驱动程序和驱动程序包,点确定;         3.无...
    99+
    2023-06-02
    win7 卸载驱动 程序
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作