MAC-mysql安装异常处理

1.打开终端,输入:open .bash_profile (如果文件不存在就 创建文件:touch .bash_profile 编辑文件:open .bash_profile)
2.直接输入如下语句:
export PATH=${PATH}:/usr/local/mysql/bin

不过如果是自动安装的上述步骤可以不用做emmm

正常启动:usr/local/mysql/share/mysql.server start
关闭:/usr/local/mysql/bin/mysqladmin -u root -p shutdown

启动程序启动服务:sudo /usr/local/MySQL/support-files/mysql.server start
关闭程序关闭服务:sudo /usr/local/mysql/support-files/mysql.server stop

删除mysql  
cd ~/
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/var/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
vim /etc/hostconfig and removed the line MYSQLCOM=-YES-rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /var/db/receipts/com.mysql.*

关闭mysql服务
2.进入mysql的bin目录执行如下命令

$ cd    
$ sudo su 

之后输入管理员密码会看到

sh-3.2# 

之后我们输入下面命令以安全模式运行mysql

sh-3.2#./mysqld_safe --skip-grant-tables &

行结束我们打开mac的系统偏好设置,选择msyql,我们会发现Mysql重新运行了如图


MAC-mysql安装异常处理_第1张图片
20160419171533381.png

回到终端点击Command + N 重新打开一个终端
输入

mysql -u -root

这时候我们不需要密码就能进入mysql

Your MySQL connection id is 57
Server version: 5.7.10 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, 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>

因为mysql5.7版本user表密码字段名字修改了

mysql> update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';

你可能感兴趣的:(MAC-mysql安装异常处理)