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.