在mysql启动时
$ mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
在mysql已经关闭时返回错误代码
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
网上很多教程都是
# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables -- skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
但是mac根本没有/etc/init.d
目录,求解
什么方法都试了,还是不管用,于是卸载后重新安装。原来是新版本的有默认密码。
新版本的mysql有一个默认的密码可以用这个密码登录到mysql,但是登录后不能执行操作,需要执行命令修改root密码,重启mysql服务,然后再用root密码就可以使用了。
谢谢各位的回答^_^