最近網(wǎng)站更換服務(wù)器,于是就連帶的升級(jí)了MySQL8,當(dāng)一切都配置好后,需要用Navicat訪問(wèn)數(shù)據(jù)庫(kù)了,按照之前的步驟操作,突然給報(bào)了錯(cuò)誤 (之前操作的鏈接:
https://www.viphper.com/1420.html)
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 'IDENTIFIED BY "password" WITH GRANT OPTION' at line 1
經(jīng)過(guò)一番努力查找,原來(lái)是mysql8不在使用之前的寫法了,之前一步的寫法需要改為兩步。
解決方法
創(chuàng)建賬戶:create user ‘用戶名’@’訪問(wèn)主機(jī)’ identified by ‘密碼’;
權(quán)限修改:grant 權(quán)限列表 on 數(shù)據(jù)庫(kù) to ‘用戶名’@’訪問(wèn)主機(jī)’ ;(修改權(quán)限時(shí)在后面加with grant option)
例子
create user 'root'@'%' identified by 'password'; #password改成你自己的密碼
grant ALL PRIVILEGES on *.* to 'root'@'%' ;
這樣按照正常的流程操作即可,可以查看我之前的文章,鏈接在上方。