ubuntu18.04卸载mysql 5.7并重新安装的方法

1 篇文章 0 订阅
1 篇文章 0 订阅

关于错误提示127的解决
以下是错误提示:

正在设置 mysql-server-5.7 (5.7.26-0ubuntu0.18.04.1) ...
/var/lib/dpkg/info/mysql-server-5.7.postinst: 行 191: /usr/share/mysql-common/configure-symlinks: 没有那个文件或目录
dpkg: 处理软件包 mysql-server-5.7 (--configure)时出错:
 installed mysql-server-5.7 package post-installation script subprocess returned error exit status 127
dpkg: 依赖关系问题使得 mysql-server 的配置工作不能继续:
 mysql-server 依赖于 mysql-server-5.7;然而:
  软件包 mysql-server-5.7 尚未配置。
 
dpkg: 处理软件包 mysql-server (--configure)时出错:
 依赖关系问题 - 仍未被配置
因为错误消息指示这是由于上一个问题导致的错误,没有写入 apport 报告。
                                                                    正在处理用于 libc-bin (2.27-3ubuntu1) 的触发器 ...
在处理时有错误发生:
 mysql-server-5.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

执行一下语句

# sudo rm /var/lib/mysql/ -R
# sudo rm /etc/mysql/ -R
# sudo apt-get autoremove mysql* --purge
# sudo apt-get install mysql-server mysql-common

会发现错误提示变成了126,还是解决不了问题,
个人感觉还是配置文件出了问题,于是打开配置文件

root@asimco-ThinkPad-X230:~# sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

就是这行在作妖
bind-address = 127.0.0.1
给他注释掉即可(前面加#),保存Ctrl+O,确定Enter并退出Ctrl+X。

root@asimco-ThinkPad-X230:~# sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
 
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address           = 127.0.0.1
#
# * Fine Tuning
#
key_buffer_size         = 16M
max_allowed_packet      = 16M
thread_stack            = 192K

,再执行一遍上面的步骤

# sudo rm /var/lib/mysql/ -R
# sudo rm /etc/mysql/ -R
# sudo apt-get autoremove mysql* --purge
# sudo apt-get install mysql-server mysql-common

进行到这一步,进程有可能会卡死(我的卡死了),
我解锁了也没用

# sudo rm /var/cache/apt/archives/lock
# sudo rm /var/lib/dpkg/lock

查找进程并杀死也没用

root@asimco-ThinkPad-X230:~# ps -e | grep apt
 3814 pts/0    00:00:01 apt-get
root@asimco-ThinkPad-X230:~# sudo kill 3814
root@asimco-ThinkPad-X230:~# sudo apt-get install mysql-server mysql-common
E: 无法获得锁 /var/lib/dpkg/lock-frontend - open (11: 资源暂时不可用)
E: 无法获取 dpkg 前端锁 (/var/lib/dpkg/lock-frontend),是否有其他进程正占用它?
 
只好重启
root@asimco-ThinkPad-X230:~# sudo reboot
Connection closing...Socket close.

重启后重新安装,竟然好了,看来还是配置文件的问题。

Welcome to Ubuntu 18.04.2 LTS (GNU/Linux 5.0.0-21-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

 * MicroK8s 1.15 is out! Thanks to all 40 contributors, you get the latest
   greatest upstream Kubernetes in a single package.

     https://github.com/ubuntu/microk8s

 * Canonical Livepatch is available for installation.
   - Reduce system reboots and improve kernel security. Activate at:
     https://ubuntu.com/livepatch

0 个可升级软件包。
0 个安全更新。

Your Hardware Enablement Stack (HWE) is supported until April 2023.
Last login: Wed Jul 17 11:23:42 2019 from 172.16.133.106
root@asimco-ThinkPad-X230:~# sudo ./setup-seafile-mysql.sh
sudo: ./setup-seafile-mysql.sh:找不到命令
root@asimco-ThinkPad-X230:~# sudo netstat -tap | grep mysql
root@asimco-ThinkPad-X230:~# sudo apt-get install mysql-server mysql-common
E: dpkg 被中断,您必须手工运行 ‘sudo dpkg --configure -a’ 解决此问题。
root@asimco-ThinkPad-X230:~# sudo dpkg --configure -a
正在设置 mysql-server-5.7 (5.7.26-0ubuntu0.18.04.1) ...
Renaming removed key_buffer and myisam-recover options (if present)
Checking if update is needed.
This installation of MySQL is already upgraded to 5.7.26, use --force if you still need to run mysql_upgrade
Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /lib/systemd/system/mysql.service.
正在设置 mysql-server (5.7.26-0ubuntu0.18.04.1) ...
root@asimco-ThinkPad-X230:~# sudo netstat -tap | grep mysql
tcp6       0      0 [::]:mysql              [::]:*                  LISTEN      2020/mysqld         
root@asimco-ThinkPad-X230:~# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.26-0ubuntu0.18.04.1 (Ubuntu)

Copyright (c) 2000, 2019, 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> quit;
Bye
root@asimco-ThinkPad-X230:~# dpkg --list|grep mysql
ii  mysql-client-5.7                           5.7.26-0ubuntu0.18.04.1                      amd64        MySQL database client binaries
ii  mysql-client-core-5.7                      5.7.26-0ubuntu0.18.04.1                      amd64        MySQL database core client binaries
ii  mysql-common                               5.8+1.0.4                                    all          MySQL database common files, e.g. /etc/mysql/my.cnf
ii  mysql-server                               5.7.26-0ubuntu0.18.04.1                      all          MySQL database server (metapackage depending on the latest version)
ii  mysql-server-5.7                           5.7.26-0ubuntu0.18.04.1                      amd64        MySQL database server binaries and system database setup
ii  mysql-server-core-5.7                      5.7.26-0ubuntu0.18.04.1                      amd64        MySQL database server binaries
root@asimco-ThinkPad-X230:~# sudo service mysql status
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2019-07-18 13:37:00 CST; 1min 50s ago
  Process: 2018 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid (code=exited, status=0/SUCCESS)
  Process: 2008 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 2020 (mysqld)
    Tasks: 28 (limit: 4455)
   CGroup: /system.slice/mysql.service
           └─2020 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid

7月 18 13:36:59 asimco-ThinkPad-X230 systemd[1]: Starting MySQL Community Server...
7月 18 13:37:00 asimco-ThinkPad-X230 systemd[1]: Started MySQL Community Server.
root@asimco-ThinkPad-X230:~# sudo service mysql start
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值