MySQL寫入許可權沒賦值被限制了怎麼處理

在專案中遇到過mysql寫入許可權沒賦值,被限制了,我們先看看提示什麼:

   

資料庫上提示的

   

伺服器上提示

解決:

The user specified as a definer ('root'@'%') does not exist 此種報錯主要是針對訪問檢視檔案引起的(沒有許可權)

按照下圖進行操作,

1.先看下mysql是否設定了環境變數,如果沒設定,就需要切換到mysql的bin目錄下執行命令(我的已經設定過了)

mysql -hlocalhost -uroot -pyx_3.0

2.給root使用者新增許可權

grant all privileges on *.* to root@"%" identified by ".";

3.重新整理許可權

flush privileges;

2:如果是在不知道密碼情況下,可以先進行重置密碼,在進行賦值許可權:

1、關閉資料庫服務

service mysqld stop

2、切換路徑至mysql安裝目錄bin下面,如:/usr/local/mysql/bin,執行如下命令:

/usr/local/mysql/bin/mysqld_safe --skip-grant-tables &

3、登入並修改密碼

mysql -u root #本機loalhost登入無需密碼

update user set password=password("newpasswd") where user="root";

flush privileges;

4、賦值許可權

grant all on *.* to 'root'@'localhost' identified by 'newpasswd' with grant option;

grant all on *.* to 'root'@'127.0.0.1' identified by 'newpasswd' with grant option;