Mac安装mysql

1、使用Homebrew安装

brew install mysql

2、开启mysql服务

mysql.server start

3、登陆mysql

mysql -u root -p

出现

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

4、停止mysql服务

mysql.server stop

4、修改密码

(1)先打开一个terminal

mysql.server stop  //先,停止mysql服务

mysqld stop  //再,停止mysqld

mysqld_safe --skip-grant-tables  //安全模式

(2)再打开一个terminal

mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
mysql> use mysql;

//两个修改方式,第一个修改方式不行,原因如下
//1、不可用
//MySQL user DB does not have password columns - Installing MySQL on OSX
mysql> update user set password=password("**passwd**") where user="root";
ERROR 1054 (42S22): Unknown column 'password' in 'field list'

//2、可用
UPDATE mysql.user SET authentication_string=PASSWORD('your password') WHERE User='root'; 

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> \q

mysql.server start

mysql -u root -p

你可能感兴趣的:(Mac安装mysql)