This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes connection to Mysql with username and password Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "connection to Mysql with username and password" Watch "connection to Mysql with username and password" New topic

connection to Mysql with username and password

sitaram irrinki
Ranch Hand

Joined: Feb 16, 2005
Posts: 158
i have installed MySql4.1.13-0 on pcq linux and it is working fine.i have created a newdatabase and new user using the following commands;

i am logging into mysql using username root and passowrd also root

mysql>create database inetdb;

mysql>grant all privilges on inetdb.* to 'student'@'localhost' identified by 'student';

i have tried to connect to inetdb database using student user using the following command

mysql --username=student --password=student inetdb

then i am able to connect to inetdb and i am able to execute any kind of staments

but if try the samething from JDBC program like

Connection con=DriverManager.getConnection("jdbc:mysql://localhost/inetdb?username=student&password=student");

it is giving an error authorization exception using password:YES

where as if i try connect to default database "test" with out username and password

Connection con=DriverManager.getConnection("jdbc:mysql://localhost/test?username=&password=");

then i am able to connect

i don't what is reason behind this.i tried the samething in is working fine.

is there any need to create the users in mysql same as operating system users
in linux
I agree. Here's the link:
subject: connection to Mysql with username and password
jQuery in Action, 3rd edition