由于之前第一次装MySQL,默认的datadir在启动盘中,我想要将datadir移动到更大的存储盘中。无奈网上的各种文章的方法在我这里总是不work。我决定重新用homebrew来装一遍MySQL。

可是由于之前各种尝试导致的乱七八糟的操作过多,以至于我连之前装MySQL的方法也用不了了。无奈之下,只得一步步摸索重来。

1. 彻底清除MySQL

之前混乱操作过多,于是只得相对彻底地把之前的痕迹清除

ps -ax | grep mysql
# stop and kill any MySQL processes # rm files and directories
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/var/mysql
sudo rm -rf /usr/local/mysql*
sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist # edit /etc/hostconfig and remove the line MYSQLCOM=-YES- # rm files and directories
rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /private/var/db/receipts/*mysql* # try to run mysql, it shouldn't work

注意,除此之外, 还要将以下文件或文件夹好好查看及清理

/tmp/  #这里有mysql.sock 以及 mysql.sock.lock 文件,我之前不小心把lock文件的user改成_mysql了,导致后面一直不work。因此,最好把这两个文件都删掉
/etc/my.cnf #这个文件当时创建以后就没扔,导致后来重装总出问题,也把这个文件删掉

2. brew install

接下来,就可以使用brew来安装了

brew doctor # and fix any errors
brew uninstall mysql
brew cleanup
brew update
brew install mysql
unset TMPDIR
mysql_install_db --verbose --user=·whoami· --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql #5.7 没有 --tmpdir选项
mysql.server start

接下来应该就没有问题了。

如果还有问题,可能是你之前已经成功登陆,但是忘了

lsof -i TCP:3306 # 找到正在占用ip的process id

kill [pid] # 终止该进程

mysql.server start

Reference

http://stackoverflow.com/questions/4359131/brew-install-mysql-on-mac-os

http://stackoverflow.com/questions/9918062/another-mysqld-server-running-on-port-3306-error

MySQL 重装的更多相关文章

  1. linux mysql重装问题

    系统 :ubuntu16.04 使用apt-get命令安装mysql,启动时出错: can't connect to local mysql server through socket '/var/r ...

  2. mysql重装之后 复制data

    (哇,编程小白的第一篇博客丫,激动) Q one:mysql需要重装,数据该怎么办. 方法一:数据表最好是导出成.sql文件,这样才比较安全. 方法二:直接copy了data文件:在mysql安装盘下 ...

  3. mysql -- 重装mysql失败的解决办法

    最近遇到一些问题,将mysql卸载了重装,但总是出现安装不成功,应该是上一个mysql没卸载干净,于是各种找资料,前后弄了几个小时,终于给弄出来了,结合网上的资料,现总结如下: 1. 打开控制面板-添 ...

  4. Ubuntu彻底删除MySQL重装MySQL

    1.删除 mysql         sudo apt-get autoremove --purge mysql-server-5.0         sudo apt-get remove mysq ...

  5. 把centos 的mysql 重装一下 把原来的lnmp删除,怎么备份还原数据库

    mysqldump --lock-all-tables -u root -p --databases mydb > /opt/database/mydb.sql,或者直接备份mysql的数据存储 ...

  6. mysql重装后出现乱码解决办法

    查看当前连接系统参数:SHOW VARIABLES LIKE '%char%'; mysql> show variables like 'char%'; +------------------- ...

  7. Ubuntu 完全卸载MySQL 重装步骤

    sudo rm /var/lib/mysql/ -R 删除mysql的数据文件   sudo rm /etc/mysql/ -R 删除mqsql的配置文件   sudo apt-get autorem ...

  8. Windows下MySQL重装引起问题的解决

    解决了Plugin 'InnoDB' init function returned error问题和error1405那个安全设置密码登陆问题,我个人觉得关键点在于删除C:/Documents and ...

  9. MySQL重装失败,could not start the service MySQL.Error:0

    MySQL5.5 安装失败现象: mysqld.exe [6132] 中发生了未经处理的 win32 异常 could not start the service MySQL.Error:0 1.在 ...

随机推荐

  1. bzoj3876: [Ahoi2014]支线剧情

    神犇题解:http://blog.csdn.net/popoqqq/article/details/43024221 题意:给定一个DAG,1为起始点,任意一个点可以直接回到1,每条边有经过代价,求一 ...

  2. 详解.Net消息队列(MSMQ)应用

    [IT168 技术文档]MSMQ是Windows 2000.Windows XP.Windows Server 2003的一个组件,并将继续包含在Windows Vista和以后的Windows服务器 ...

  3. bzoj 3172: [Tjoi2013]单词

    #include<cstdio> #include<cstring> #include<iostream> #define M 1000008 using name ...

  4. Erlang中如何在同一台机器上运行多个erlang节点?

    首先打开shell,然后在打开cmd输入:erl -sname bilbo  这样就启动了一个gandal的erlang节点. 如图:

  5. python学习03——设计,与input有关

    笨办法学python第36节,我写的代码如下: from sys import exit def rule(): print "Congratulations! You made the r ...

  6. reds Virtual Memory

    Virtual Memory technical specification This document details the internals of the Redis Virtual Memo ...

  7. linux内核学习之四 系统调用

    一  概念区分 提到linux系统调用,不得不区分几个比较容易混淆的概念: 系统调用:系统调用就是一种特殊的接口.通过这个接口,用户可以访问内核空间.系统调用规定了用户进程进入内核的具体位置. 应用程 ...

  8. stella mccartney falabella foldover tote a few eye observed

    Lately, the particular Heyuan City Courtroom retrial, in order to commit the criminal offense of cou ...

  9. 使用jQuery实现点击左右滑动切换特效

    使用jQuery实现点击左右滑动切换特效: HTML代码如下: <!--整体背景div--> <div class="warp"> <!--中间内容d ...

  10. Android性能优化之使用线程池处理异步任务

    转:http://blog.csdn.net/u010687392/article/details/49850803