1. the program connecting Unknowncharacterset: utf8mb4 is packageqdu. wxyz. db; importjava. SQL. connection; importjava. SQL. driverManager; importjava. SQL. SQLException; publicclassConn {staticConnectionconn; publicConn () {connnull;} public
1. the program connecting Unknown character set: 'utf8mb4' is package qdu. wxyz. db; import java. SQL. connection; import java. SQL. driverManager; import java. SQL. SQLException; public class Conn {static Connection conn; public Conn () {conn = null;} public
1. Unknown character set: 'utf8mb4'
The Connection Program is:
Package qdu. wxyz. db;
Import java. SQL. Connection;
Import java. SQL. DriverManager;
Import java. SQL. SQLException;
Public class Conn {
Static Connection conn;
Public Conn (){
Conn = null;
}
Public Connection getConnection (){
Try {
Class. forName ("com. mysql. jdbc. Driver ");
Conn =
DriverManager. getConnection ("jdbc: mysql: // localhost: 3306/wxyz? UseUnicode = true & characterEncoding = UTF-8 ",
"Ximo", "ximo"); // url, username, password;
// System. out. println (conn + "123 ");
} Catch (ClassNotFoundException e ){
// TODO Auto-generated catch block
E. printStackTrace ();
}
// Connect to the database
Catch (SQLException e ){
// TODO Auto-generated catch block
E. printStackTrace ();
}
Return conn;
}
}
The user name and password are correct. An error occurred while running.
Solution: Wrong driver, different versions will have this error, the modified version corresponding to "mysql5.6 corresponding mysql-connertor-java-5.1.30-bin.jar
> Mysql-connertor-java-5.1.8-bin.jar for mysql6.0
2. If the user password is incorrect, run the following command:
View all users in the MYSQL database
Mysql> select distinct concat ('user: ''', User, ''' @ ''', host, '''; ') AS query FROM mysql. user;
The command for permission is:
View permissions of a specific user in the database
Mysql> show grants for 'cactiuser' @ '% ';
Mysql> select * from mysql. user where user = 'cactiuser' \ G
To view the structure of a user table, you can use the table structure to query specific items.
Mysql> desc mysql. user;