Mac安装Server version: 5.7.19 MySQL Community Server (GPL)的整个过程
1.下载mysql
mysql-5.7.19-macos10.12-x86_64.dmg
2.常规安装-一步一步点击下去安装
mysql-5.7.19-macos10.12-x86_64.dmg
3.打开mysql服务
在
系统偏好设置里边
点击MySql这个图标-然后选择启动mysql就行了,记着勾选下面的按钮,这样就每次mac开机时,Mysql服务就自动开启了
打开后界面上红色的部分会变成绿色的
running
。
4.mysql
配置路径
用文本编辑器打开.bash_profile
,加入PATH=$PATH:/usr/local/mysql/bin
并保存。我习惯用 Atom 作为文本编辑器,或者直接用自带的 vim 编辑。在命令行输入source ~/.bash_profile
路径就配置好了。
以上情况是基于bash的配置方法
simthdeMacBook-Pro:~ a6$ vi ~/.bash_profile
simthdeMacBook-Pro:~ a6$ source ~/.bash_profile
5.登陆并修改密码
mysql -u root -p
登陆,输入之前保存的密码
安装完mysql5.7
之后,登陆以后,不管运行任何命令,总是提示这个
You must reset your password using ALTER USER statement before executing this statement.
此时你需要做的是修改密码呢
step 1: SET PASSWORD = PASSWORD(‘your new password‘);
step 2: ALTER USER ‘root‘@‘localhost‘ PASSWORD EXPIRE NEVER;
step 3: flush privileges;
完成以上三步退出再登,使用新设置的密码就行了,以上除了红色的自己修改成新密码外,其他原样输入即可
具体操作如下:
simthdeMacBook-Pro:~ a6$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 223
Server version: 5.7.19
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> SET PASSWORD = PASSWORD('XXX!123XX456')
-> ;
Query OK, 0 rows affected, 1 warning (0.00 sec)
就会出现如下提示,这个时候已经更新了密码,但是会有 warning。如果想查看warning,可以用
show warning
mysql> ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)