PDA

View Full Version : Can't connect to mySQL. Please help


mpls2000
04-15-2003, 09:57 AM
I am trying to connect to the mySQL in my local PC.

This is the code in my Java application:
Properties props = new Properties();
props.put("user","admin");
props.put("password", "admin");
myDriver = new org.gjt.mm.mysql.Driver();
connection = myDriver.connect ("jdbc:mysql://localhost:3306/mysql", props);

I got the following result:
D:\test>java -cp .;d:\Tomcat4.1\common\lib\mysql-connector-java-3.1.0-alpha-bin.
jar Test
java.sql.SQLException: Communication failure during handshake. Message from serv
er: "Access denied for user: 'admin@127.0.0.1' to database 'mysql'"

I did created a "admin" user in mysql. See below:
D:\mysql\bin>mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 25 to server version: 4.0.10-gamma-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use mysql
Database changed
mysql> select host,user,password from user;
+-----------+-------+------------------+
| host | user | password |
+-----------+-------+------------------+
| localhost | root | |
| % | root | |
| localhost | | |
| % | | |
| % | admin | 43e9a4ab75570f5b |
| localhost | admin | 43e9a4ab75570f5b |
+-----------+-------+------------------+
6 rows in set (0.05 sec)

mysql>

What is wrong??? Please help. Thank you.