主题:最近装了mysql4.0.22版本出了问题。大家进来帮帮忙。谢谢了。
C:\Documents and Settings\zqc>cd c:\mysql\bin
C:\mysql\bin>use mysql
ERROR 1044: Access denied for user: '@localhost' to database 'mysql'
C:\mysql\bin>
以下是jsp页面连接mysql的时候的错误:
exception
javax.servlet.ServletException: Access denied for user: '@localhost' (Using password: YES)
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.test_jsp._jspService(test_jsp.java:94)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.sql.SQLException: Access denied for user: '@localhost' (Using password: YES)
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2901)
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:773)
com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1258)
com.mysql.jdbc.Connection.createNewIO(Connection.java:1699)
com.mysql.jdbc.Connection.<init>(Connection.java:408)
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:270)
java.sql.DriverManager.getConnection(DriverManager.java:512)
java.sql.DriverManager.getConnection(DriverManager.java:193)
org.apache.jsp.test_jsp._jspService(test_jsp.java:56)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
以下是我的测试连接代码:
<%@ page contentType="text/html;charset=GB2312" %>
<%@ page import="java.sql.*"%>
<html>
<head>
<title>测试mysql</title>
</head>
<body>
<%
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
}catch(Exception e){e.printStackTrace();}
String url="jdbc:mysql://localhost/mysql? user=root&password=801009&useUnicode=true&characterEncoding=GB2312";
Connection conn=DriverManager.getConnection(url);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from testmysql";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()){%>
你的第一个字段为:<%=rs.getString(1)%>
你的第二个字段为:<%=rs.getString(2)%>
<%}%>
<%out.println("数据库操作成功!恭喜你!");%>
<%
rs.close();
stmt.close();
conn.close();
%>
</body>
</html>
原来用的是4.0.16都没有什么问题的。可是后来卸载以后,直接装了4.0.22了。。就变成这样了。
C:\mysql\bin>use mysql
ERROR 1044: Access denied for user: '@localhost' to database 'mysql'
C:\mysql\bin>
以下是jsp页面连接mysql的时候的错误:
exception
javax.servlet.ServletException: Access denied for user: '@localhost' (Using password: YES)
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.test_jsp._jspService(test_jsp.java:94)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.sql.SQLException: Access denied for user: '@localhost' (Using password: YES)
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2901)
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:773)
com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1258)
com.mysql.jdbc.Connection.createNewIO(Connection.java:1699)
com.mysql.jdbc.Connection.<init>(Connection.java:408)
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:270)
java.sql.DriverManager.getConnection(DriverManager.java:512)
java.sql.DriverManager.getConnection(DriverManager.java:193)
org.apache.jsp.test_jsp._jspService(test_jsp.java:56)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
以下是我的测试连接代码:
<%@ page contentType="text/html;charset=GB2312" %>
<%@ page import="java.sql.*"%>
<html>
<head>
<title>测试mysql</title>
</head>
<body>
<%
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
}catch(Exception e){e.printStackTrace();}
String url="jdbc:mysql://localhost/mysql? user=root&password=801009&useUnicode=true&characterEncoding=GB2312";
Connection conn=DriverManager.getConnection(url);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from testmysql";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()){%>
你的第一个字段为:<%=rs.getString(1)%>
你的第二个字段为:<%=rs.getString(2)%>
<%}%>
<%out.println("数据库操作成功!恭喜你!");%>
<%
rs.close();
stmt.close();
conn.close();
%>
</body>
</html>
原来用的是4.0.16都没有什么问题的。可是后来卸载以后,直接装了4.0.22了。。就变成这样了。