為什么使用homebrew安裝mysql?
使用homebrew安裝mysql不用考慮版本的問題。
直接使用以下指令即可進(jìn)行安裝
brew install mysql
安裝完成后,啟用mysql
$mysql.server start
Starting MySQL
.. SUCCESS!
現(xiàn)在登錄mysql,默認(rèn)情況下免密登錄
$ mysql -u root
更新root密碼,使用set的方式出錯了,提示我檢查mysql的版本,我的mysql版本是8.0
mysql> update user set password=PASSWORD('root') WHERE user='root';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('root') WHERE user='root'' at line 1
查看mysql版本
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.15 |
+-----------+
1 row in set (0.00 sec)
使用下面的方式更改密碼
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
然后輸入 exit 退出
mysql> exit
Bye
使用密碼登錄
$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 20
Server version: 8.0.15 Homebrew