下载mysql
https://www.mysql.com/downloads/
1,安装dmg文件,安装完成后,执行如下命令,查看mysql版本
<code>mysql --version</code>
显示版本号说明正常,若显示command not found,在终端输入如下,”/usr/local/mysql/bin/mysql”为mysql默认安装路径:
cd /usr/local/bin/
sudo ln -fs /usr/local/mysql/bin/mysql mysql
2,关闭mysql服务
sudo /usr/local/mysql/support-files/mysql.server stop
3,修改root密码
进入myslq的安全模式
sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables
修改密码,逐行输入
mysql -u root
UPDATE mysql.user SET authentication_string=PASSWORD('这里是密码') WHERE User='root';
FLUSH PRIVILEGES;
\q
4,配置完成,验证一下吧
mysql -u root -p