• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

How to get authorized using MySql?

 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I run MySql under Solaris 8 very well. I inserted a user called jack into the user table
of mysql database like this:
mysql>INSERT INTO user (Host, User, Password)
-> VALUES('localhost', 'jack', PASSWORD('johnson'));
Query OK, 1 row affected (0.00 sec)
I checked the table, and see that user jack is there.
Here is a part of my JDBC test code, which accesses the demodb database I have created for test use.
import java.net.*;
import java.sql.*;
import java.io.*;
import java.util.*;
class MySqlTest
{ public static void main(String [] args)
{ try
{ Class.forName ("org.gjt.mm.mysql.Driver");
java.sql.Connection con;
con=DriverManager.getConnection("jdbc:mysql://localhost/demodb", "jack", "johnson");
......
}
The code compiles successfully, but when I run the bytecode, I get an exception. Look here:
# java MySqlTest
java.sql.SQLException: Invalid authorization specification: Access denied for user: 'jack@localhost' (Using password: YES)
#

Don't worry about the driver. I think the driver is working well, otherwise, I would have got another exception concerning the driver.
So what is the problem? How should I fix it please?
Thanks a lot.
[ March 10, 2002: Message edited by: Gene Chao ]
 
author
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You must add jack@localhost in your access table. In my system, the domain added by the commandline tool is "username@localhost.localdomain" or username@real_host_name
I suggest you to log in from the commandline utility and explicitly run the following:
mysql> GRANT ALL PRIVILEGES ON *.* TO jack@localhost IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
 
Mark Lau
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. How do I add that thing to the access table? What do you mean by access table? Are you referring to the user table of mysql database? Thanks.
 
Michael Yuan
author
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I meant the user table. I think the above GRANT command should take care of this for you ...
 
New rule: no elephants at the chess tournament. Tiny ads are still okay.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic