我可以通过命令行访问mysql,我已经看到了几个关于这个的问题,但它没有用。
我试过了:
1.mysql>将。的所有权限授予root密码'标识的root @ localhost。有补助金;
2.创建一个新用户;
3.修改密码;
这是我的用户'资讯
的MySQL>从mysql.user中选择用户,主机,密码;
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| root | localhost | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| root | 127.0.0.1 | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+------+-----------+-------------------------------------------+
/* 15 */ String driver = "";
/* 16 */ String url = "";
/* 17 */ driver = "com.mysql.jdbc.Driver";
/* 18 */ url = "jdbc:mysql://localhost:3306/demo?characterEncoding=utf-8";
/* 19 */ Connection con = null;
/* 20 */ String user = "root";
/* 21 */ String pwd = "root";
/* */ try {
/* */ try {
/* 25 */ Class.forName(driver);
/* */ } catch (ClassNotFoundException ex) {
/* 27 */ ex.printStackTrace();
/* */ }
System.out.println("url:"+url+" user="+user+" pwd="+pwd);
/* 29 */ con = DriverManager.getConnection(url, user, pwd);
/* */ } catch (SQLException ex) {
/* 31 */ ex.printStackTrace();
/* */ }

答案 0 :(得分:0)