Mac下安装与配置MySQL

步骤:

1、官网下载mysql安装包mysql-5.7.13-osx10.11-x86_64.bmg安装

2、安装完成后终端输入:

mysql --version

----显示版本号说明正常,若显示command not found,在终端输入如下,”/usr/local/mysql/bin/mysql”为mysql默认安装路径:

$ cd /usr/local/bin/

$ sudo ln -fs /usr/local/mysql/bin/mysql mysql

3、关闭mysql服务:

sudo /usr/local/mysql/support-files/mysql.server stop

4、配置root账号的密码,默认没有配置,

-----在终端内输入(开启安全模式启动mysql):

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

5、配置完成后验证,在终端输入:

mysql -u root -p

----提示输入密码,进入mysql说明成功!

mysql>

6、mysql服务启动和关闭可以在系统偏好设置里面操作,终端命令如下:

$ sudo /usr/local/mysql/support-files/mysql.server start
$ sudo /usr/local/mysql/support-files/mysql.server stop