首先在mysql官网下载应用http://dev.mysql.com/downloads/ 选择MySQL Community Server
下载完后直接普通点击安装,安装完后不着急启动mysql,需要重置下root密码!
在终端中 sudo mysqld_safe--skip-grant-tables (以安全模式运行,绕过root密码检验,需上步骤中停止mysql服务)
另起新的终端:
mysql -u root
update user set authentication_string=password('yourpassword') where user='root';
FLUSH PRIVILEGES;
\q
-----------------------------
mysql -uroot -pyourpassword
在终端进行操作时报 ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
需要给用户设置新密码(已经以root登陆)
SET PASSWORD = PASSWORD('your_new_password');