mac下mysql安装、卸载、基本操作
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
执行mysql报错
mac下运行mysql报错
ERROR 1045 (28000): Access denied for user 'zhang'@'localhost' (using password: NO)
解决很简单,执行命令sudo mysql即可
或者执行命令,mysql -u root
再解决不了,我就不知道了啊,你可以按照下边的方便,卸载了重装。
关闭运行的mysqld
比较暴力的方式:
查看mysql是否启动:ps -ef |grep mysql
输入:kill -9 (./mysqld前面第二个数字,这里是627) 然后回车
输入:ps -ef |grep mysql 就可以继续查看进程在不在:
删除mysql
删除前请确认是不是已经关闭运行的mysql,看上面
brew remove mysql
brew cleanup
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 -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /private/var/db/receipts/*mysql*
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
安装
1.执行
brew install mysql
- 1
2.安装完 mysql 后,他会提示你 init database,并提供下面这两句让你执行,很可能你没执行这两句
unset TMPDIR
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
- 1
- 2
3.然后就可以指向 mysql.server start 来启动了,为了安全,你还可以执行安全设置向导,根据提示一步一步配置
mysql_secure_installation
- 1
4.最后启动
mysql.server start
- 1
参考地址
https://blog.csdn.net/xiaozh620/article/details/77530893
https://segmentfault.com/q/1010000000094608
漫思