赞
踩
首先查看mac中是否已经安装了mysql,这个应该是系统自带的,本人并不知道账号和密码
打开系统偏好设置,点击mysql图标,可以start/stop mysql运行;
如果想登陆,可以如下操作:
1、关闭mysql服务: 苹果->系统偏好设置->最下边点mysql 在弹出页面中 关闭mysql服务(点击stop mysql server)
退出数据库后,再在终端stop,发现,stop后没有生效,,,,重启电脑后可以stop了
2、进入终端输入:cd /usr/local/mysql/bin/
回车后 登录管理员权限 sudo su
回车后输入以下命令来禁止mysql验证功能 ./mysqld_safe --skip-grant-tables &
回车后mysql会自动重启(偏好设置中mysql的状态会变成running)
3、输入命令 ./mysql -u root
回车后,输入命令 FLUSH PRIVILEGES;
回车后,输入命令 SET PASSWORD FOR 'root'@'localhost' = PASSWORD('你的新密码'); 回车后报错:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PASSWORD('root')' at line 1
更新密码的sql语句找到适合自己的,我这里用:ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';可以成功修改
UPDATE mysql.user SET authentication_string=PASSWORD('root') WHERE User='root';
update mysql.user set authentication_string=password('root') where user='root' and Host = 'localhost';
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
退出后,可以mysql -u root -p登录数据库了
以上方法不一定适用所有情况,具体报错再百度解决即可!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。