mac系统新装mysql设置root密码
mac新装mysql设置root密码
默认mac版的mysql安装后root没有密码,但直接在user表里对root添加密码时后,重新登陆,又报一个诡异的错误:
# mysqladmin -uroot -p password 'newpassword'
Enter password:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
ps:
mysql默认在安装后mysqladmin命令不是全局的,如果要设置为全部的,需要设置自启动(mysql的命令行默认在/usr/local/mysql/bin/下)
# /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
# /etc/init.d/mysql restart
# mysql -uroot -p
Enter password: <输入新设的密码newpassword>