Home  >  Article  >  Database  >  mysql 连接时的错误_MySQL

mysql 连接时的错误_MySQL

WBOY
WBOYOriginal
2016-06-01 13:06:52862browse

1.Unknown character set: 'utf8mb4'

连接的程序为:

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();
}
//连接数据库
catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return conn;
}
}


用户名密码没有错误,运行出错

解决方案:驱动用错了,版本不同就会有这种错误,修改后版本对应为》mysql5.6 对应mysql-connertor-java-5.1.30-bin.jar

>>mysql6.0对应mysql-connertor-java-5.1.8-bin.jar



2.如果是用户密码错误,可以使用指令:

查看MYSQL数据库中所有用户
mysql> SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;

然后权限的指令为:

查看数据库中具体某个用户的权限
mysql> show grants for 'cactiuser'@'%';

mysql> select * from mysql.user where user='cactiuser' /G

查看user表结构 需要具体的项可结合表结构来查询
mysql> desc mysql.user;















Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn