/usr/local/etc/my.cnf
,也有多是/etc/my.cnf
vim my.cnf
找到mysql服務路徑,我這裏是/usr/local/Cellar/mysql/8.0.17/support-files/mysql.server
html
cd /usr/local/Cellar/mysql/8.0.17/support-files mysql.server restart
mysql -uroot -p
(不須要密碼直接Enter)進入mysql命令行執行mysql
mysql> update user set password=password("*******") where user="*******"; #修改密碼報錯
若是上面報錯ERROR 1054 (42S22): Unknown column 'password' in 'field list'
,sql
(錯誤的緣由是 5.7版本下的mysql數據庫下沒有password這個字段,password字段改爲了authentication_string)數據庫
請嘗試如下語句vim
mysql> update mysql.user set authentication_string=password('*******') where user='*******'; #修改密碼成功 Query OK, 1 row affected, 1 warning (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 1
若是以上命令仍是不行,那麼請嘗試ui
mysql> flush privileges; #當即生效 mysql> ALTER user 'root'@'localhost' IDENTIFIED BY '12345678';
mysql> flush privileges; #當即生效 Query OK, 0 rows affected (0.00 sec) mysql> quit #退出mysql -- 也能夠使用 exit;命令 Bye
從新執行vim /etc/my.cnf,而後刪除剛剛加入的 skip-grant-tables,從新啓動mysqlspa