【问题标题】:How to uninstall the unused version of MySQL on a mac?如何在 Mac 上卸载未使用的 MySQL 版本?
【发布时间】:2017-10-03 07:57:39
【问题描述】:

我正在运行 mac OS sierra,并且在机器上安装了多个 MySQL。一个是手动安装的,另一个是用 Homebrew 安装的。我连接和使用 MySQL 没有问题,我认为它是 Homebrew 版本,但老实说我不知道​​。

我正在处理一个 sock 错误,该错误表明我正在使用的应用程序无法连接到 MySQL(在我的本地 Mac 上),从那以后我一直在挖掘。该应用程序通过 http 运行,连接应该没有问题,但我收到以下错误,导致我发现了两个 mysql 安装。有道理,因为当我拿到机器时,我安装了 mysql,然后才开始使用自制软件。

Connection Test Failed:
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

任何想法如何首先确定默认使用哪个版本然后删除未使用的版本?请注意,默认运行的实例可以通过我用来管理本地数据库的所有客户端正常连接。

更新: 在 Cellar /usr/local/Cellar/mysql/5.6.25 中有一个文件夹,然后在 /usr/local/var/mysql/ 中有另一个版本,这是我所有数据库所在的那个。

mysqld stop 呈现以下错误并让我相信 mysqld 正在控制我要删除的 MySQL 版本:

$ mysqld stop

2017-05-04 18:44:54 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2017-05-04 18:44:54 0 [Note] mysqld (mysqld 5.6.25) starting as process 1718 ...

2017-05-04 18:44:54 1718 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive

2017-05-04 18:44:54 1718 [Note] Plugin 'FEDERATED' is disabled.

2017-05-04 18:44:54 1718 [Note] InnoDB: Using atomics to ref count buffer pool pages

2017-05-04 18:44:54 1718 [Note] InnoDB: The InnoDB memory heap is disabled

2017-05-04 18:44:54 1718 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2017-05-04 18:44:54 1718 [Note] InnoDB: Memory barrier is not used

2017-05-04 18:44:54 1718 [Note] InnoDB: Compressed tables use zlib 1.2.3

2017-05-04 18:44:54 1718 [Note] InnoDB: Using CPU crc32 instructions

2017-05-04 18:44:54 1718 [Note] InnoDB: Initializing buffer pool, size = 128.0M

2017-05-04 18:44:54 1718 [Note] InnoDB: Completed initialization of buffer pool

2017-05-04 18:44:54 1718 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 35

2017-05-04 18:44:54 1718 [Note] InnoDB: Check

 or log files.

2017-05-04 18:43:41 1635 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 35

2017-05-04 18:43:41 1635 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.

【问题讨论】:

    标签: mysql linux macos homebrew


    【解决方案1】:

    只需使用psgrep 命令即可:

    ➜  ps -ef|grep mysqld
      501 51092     1   0         0:00.03 /bin/sh /usr/local/opt/mysql/bin/mysqld_safe --bind-address=127.0.0.1 --datadir=/usr/local/var/mysql
      501 51194 51092   0         0:00.45 /usr/local/Cellar/mysql/5.7.17/bin/mysqld --basedir=/usr/local/Cellar/mysql/5.7.17 --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/Cellar/mysql/5.7.17/lib/plugin --bind-address=127.0.0.1 --log-error=/usr/local/var/mysql/McGrady.local.err --pid-file=/usr/local/var/mysql/McGrady.local.pid
    

    上面的结果是程序和选项的路径,对我来说,我的数据目录是--datadir=/usr/local/var/mysql,所以你会找到你需要的。

    如果您通过brew services start mysql 运行mysql,您也可以使用brew services list 来执行此操作:

    ➜  brew services list
    Name    Status  User  Plist
    mysql   started ** /Users/**/Library/LaunchAgents/homebrew.mxcl.mysql.plist
    
    ➜  cat /Users/**/Library/LaunchAgents/homebrew.mxcl.mysql.plist
      ...
      <array>
        <string>/usr/local/opt/mysql/bin/mysqld_safe</string>
        <string>--bind-address=127.0.0.1</string>
        <string>--datadir=/usr/local/var/mysql</string>
      </array>
      ...
    

    在这里,我们可以得到datadir 选项。

    [ERROR] InnoDB: Unable to lock ./ibdata1, error: 35
    

    上面的错误只是告诉你一些其他进程(可能是 mysqld 的另一个实例)已经锁定了文件。这意味着如果你已经启动了一个mysql服务器,下次运行mysqld命令时,你会得到这个错误。

    您可以查看this question 找到停止服务器的方法。

    或者只是kill -9 pid杀死进程,卸载mysql如果你想删除brew安装的,你可以运行这个:

    brew uninstall mysql
    

    另一个,你可以使用:

    sudo rm -rf /path_you_install_mysql.*
    

    看看How do you uninstall MySQL from Mac OS X?

    【讨论】:

      猜你喜欢
      • 2019-08-06
      • 2015-10-18
      • 2010-11-04
      • 2020-07-27
      • 1970-01-01
      • 2018-10-07
      • 1970-01-01
      • 1970-01-01
      • 2010-11-29
      相关资源
      最近更新 更多