Hello, I am having a problem connecting to a mysql database. My url string is as follows: private static final String url = "jdbc:mysql://localhost:3306/therezworks"; and I call the DriverManager with: DriverManager.getConnection(url, userName, password); The output of this is: ------SQLException------ Error message: Invalid authorization specification: Access denied for user: 'firstname.lastname@example.org' (Using password: YES) SQLState: 28000 Vendor: 1045
Further, you may have to grant access privileges to your user name. Check it here HTH -- Venkat
Joined: Jan 25, 2002
Hi, I have done a: GRANT ALL PRIVILEGES ON therezworks.* TO chris@localhost IDENTIFIED BY 'some_pass' but I still see the error. I don't understand what I'm doing wrong. I am able to connect to mysql using: mysql -u chris -p and access all of the tables in my database, but I am not given access when attempting to get to them via a servlet. c.
MySQL Connector/J must use TCP/IP sockets to connect to MySQL, as Java does not support Unix Domain Sockets. Therefore, when MySQL Connector/J connects to MySQL, the security manager in MySQL server will use its grant tables to determine whether or not the connection should be allowed.
You must add grants to allow this to happen. The following is an example of how to do this (but not the most secure).
From the mysql command-line client, logged in as a user that can grant privileges, issue the following command:
GRANT ALL PRIVILEGES ON [dbname].* to '[user]'@'[hostname]' identified by '[password]'
replacing [dbname] with the name of your database, [user] with the user name, [hostname] with the host that MySQL Connector/J will be connecting from, and [password] with the password you want to use. Be aware that RedHat Linux is broken with respect to the hostname portion for the case when you are connecting from localhost. You need to use "localhost.localdomain" for the [hostname] value in this case. Follow this by issuing the "FLUSH PRIVILEGES" command.