The user specified as a definer ("@") does not exist Solution

Source: Internet
Author: User
Export the SQL script database from the company using navicat, and import it back. The console reports the following error when running the project:
Caused by: Java. SQL. sqlexception: the user specified as a definer (''@'') does not exist
At com. MySQL. JDBC. sqlerror. createsqlexception (sqlerror. Java: 1075)
At com. MySQL. JDBC. mysqlio. checkerrorpacket (mysqlio. Java: 3566)
At com. MySQL. JDBC. mysqlio. checkerrorpacket (mysqlio. Java: 3498)
At com. MySQL. JDBC. mysqlio. sendcommand (mysqlio. Java: 1959)
At com. MySQL. JDBC. mysqlio. sqlquerydirect (mysqlio. Java: 2113)
At com.mysql.jdbc.connectionimpl.exe csql (connectionimpl. Java: 2568)
At com.mysql.jdbc.preparedstatement.exe cuteinternal (preparedstatement. Java: 2113)
At com.mysql.jdbc.preparedstatement.exe cutequery (preparedstatement. Java: 2275)
At com.mchange.v2.c31_impl.newproxypreparedstatement.exe cutequery (newproxypreparedstatement. Java: 76)
At org. hibernate. JDBC. abstractbatcher. getresultset (abstractbatcher. Java: 186)
At org. hibernate. loader. loader. getresultset (loader. Java: 1787)
At org. hibernate. loader. loader. docquery (loader. Java: 674)
At org. hibernate. loader. loader. doqueryandinitializenonlazycollections (loader. Java: 236)
At org. hibernate. loader. loader. dolist (loader. Java: 2220)
... 73 more

The preceding error occurs when a new project is uploaded to the server. The error indicates that the user '@' does not exist during database access. when creating a view and storage process, directly copy the code in the MySQL visual graphics tool to the server for running. MySQL will automatically generate some code, such as the copied view statement:
------------------------------
-- View Structure for 'sys _ teacher_role_view'
------------------------------
Drop view if exists 'sys _ teacher_role_view ';
Create algorithm = undefined definer = ''@'' SQL Security definer view 'sys _ teacher_role_view'As select 'tea _ teacher '. 'teaid 'as 'teaid ', 'sys _ user_role '. 'employee _ nember' as 'employee _ nember', 'tea _ teacher '. 'staffnumbers 'As 'staffnumbers', 'tea _ teacher '. 'teachername' as 'teachername', 'sys _ user_role '. 'Role _ id' as 'role _ id', 'tea _ teacher '. 'Identity _ Card' as 'Identity _ card' from ('tea _ teacher' left join 'sys _ user_role' on ('sys _ user_role '. 'employee _ nember' = 'tea _ teacher '. 'teaid ')));

It should be changed:
------------------------------
-- View Structure for 'sys _ teacher_role_view'
------------------------------
Drop view if exists 'sys _ teacher_role_view ';
Create view 'sys _ teacher_role_view'As select 'tea _ teacher '. 'teaid 'as 'teaid ', 'sys _ user_role '. 'employee _ nember' as 'employee _ nember', 'tea _ teacher '. 'staffnumbers 'As 'staffnumbers', 'tea _ teacher '. 'teachername' as 'teachername', 'sys _ user_role '. 'Role _ id' as 'role _ id', 'tea _ teacher '. 'Identity _ Card' as 'Identity _ card' from ('tea _ teacher' left join 'sys _ user_role' on ('sys _ user_role '. 'employee _ nember' = 'tea _ teacher '. 'teaid ')));

The same is true for Stored Procedures, which tend to ignore this problem and cause the above errors.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.