进入网址:
https://dev.mysql.com/downloads/mysql/
选择dmg
(选择dmg文件的好处就是傻瓜式安装,下一步下一步就好。)
直接下载
MySQL安装完之后,会弹出一个对话框,显示着一个临时的root密码,为了省事儿请备份好该密码,下文会有介绍如何更换密码,忘了也没事,有更改密码的方法:
Have you forgotten your Mac OS X 'ROOT' password and need to reset it?
Follow these 4 simple steps:
1. Stop the mysqld server.
Typically this can be done by from 'System Prefrences' > MySQL > 'Stop MySQL Server'
2. Start the server in safe mode with privilege bypass
From a terminal:
sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables
3. In a new terminal window:
sudo /usr/local/mysql/bin/mysql -u root
UPDATE mysql.user SET authentication_string=PASSWORD('your_new_password') WHERE User='root';
FLUSH PRIVILEGES;
\q
4. Stop the mysqld server again and restart it in normal mode.
# 如果停止不了使用命令:sudo /usr/local/mysql/support-files/mysql.server stop
为了以后能在终端中运行mysql的命令,打开终端输入以下两条命令:
alias mysql=/usr/local/mysql/bin/mysql
alias mysqladmin=/usr/local/mysql/bin/mysqladmin
之后输入以下命令可以查看mysql版本信息:
mysql --version
版本信息
接下来进入系统偏好设置,最下边一行,找到mysql打开,点击"Start MySQL Server",启动mysql:
启动mysql
然后重置密码,newpassword改为你自己想设的密码:
mysqladmin -u root -p password newpassword
终端会让你输入原始密码,就是安装完弹出的那个,可以在通知栏中找到(如果报ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)错就用上面更改密码的方法):
原始密码
改完密码后输入命令,然后输入新密码测试:
mysql -u root -p
至此,mysql便安装配置完成。
网友评论