2017-05-05 63 views
0

我運行Mac OS Sierra和在機器上的MySQL的一個以上的安裝。一個手動安裝,另一個安裝Homebrew。我沒有問題連接和使用MySQL,我認爲這是Homebrew版本,但我真的不知道。如何在Mac上卸載未使用的MySQL版本?

我處理的指示,我使用的應用程序無法連接到MySQL的(在我的本地MAC)襪子錯誤,我一直在其後挖掘。該應用程序通過http運行,並且不應該有連接問題,但我得到下面的錯誤,導致我找出有關兩個安裝的MySQL。有道理,因爲當我得到機器時,我在成爲髖關節之前安裝了mysql。

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

任何想法如何首先確定哪些是默認使用,然後刪除版本不被使用?請注意,默認運行的實例可以通過我用來管理本地數據庫的所有客戶端進行連接。

更新: 有酒窖/usr/local/Cellar/mysql/5.6.25一個文件夾裏面,然後有在/ usr /本地的/ var/mysql的另一個版本/這是一個所有我數據庫是。

的mysqld停止呈現以下錯誤,導致我相信,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. 

回答

0

只需使用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 list要做到這一點,如果通過brew services start mysql運行mysql:

➜ 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 uninstall mysql 

再一個,你可以使用:

sudo rm -rf /path_you_install_mysql.* 

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