mysql The user specified as a definer ('XX'@'%') does not exist

來源:互聯網
上載者:User

標籤:存在   name   nbsp   伺服器   資料庫名   授權   username   base   local   

  測試組人員在做完資料庫遷移後,項目運行後,發現有的sql報The user specified as a definer (‘XX‘@‘%‘) does not exist的錯誤。上網查詢後發現是許可權問題。

  解決法案如下:

  1.如果資料庫中不存在xx使用者,則建立xx使用者

    CREATE USER ‘XX‘@‘%‘ IDENTIFIED BY ‘password‘;

     2.給xx授權

    grant all privileges on *.* to [email protected]"%" identified by ".";

    flush privileges;

 

  建立使用者命令:

  CREATE USER ‘username‘@‘host‘ IDENTIFIED BY ‘password‘;

  說明:username - 你將建立的使用者名稱, host - 指定該使用者在哪個主機上可以登陸,如果是本機使用者可用localhost, 如果想讓該使用者可以從任意遠程主機登陸,可以使用萬用字元%.

    password - 該使用者的登陸密碼,密碼可以為空白,如果為空白則該使用者可以不要求輸入密碼登陸伺服器。

  

 

  授權命令:

  GRANT privileges ON databasename.tablename TO ‘username‘@‘host‘ IDENTIFIED BY ‘mypassword‘ WITH GRANT OPTION; 

  說明:privileges - 使用者的操作許可權,如SELECT , INSERT , UPDATE 等。如果要授予所的許可權則使用ALL。;databasename - 資料庫名,tablename-表名,如果要授予該使用者對所有資料庫和表的相應操作許可權則可用*表示, 如*.*。

  IDENTIFIED BY ‘mypassword‘ 串連密碼。

  例子:如果你想允許使用者myuser從ip為192.168.1.6的主機串連到mysql伺服器,並使用mypassword作為密碼 

  GRANT ALL PRIVILEGES ON *.* TO ‘myuser‘@‘192.168.1.3‘ IDENTIFIED BY ‘mypassword‘ WITH GRANT OPTION; 

  FLUSH   PRIVILEGES;  

    

  

 

mysql The user specified as a definer ('XX'@'%') does not exist

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.