If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > MXJ Connector - How to create new username

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-03-10, 20:10
honeywish honeywish is offline
Registered User
 
Join Date: Oct 2010
Posts: 3
MXJ Connector - How to create new username

Hi,

I need to make an application with mySQL embedded, so I was testing out mySQL's mjx connection with the code on:MySQL :: MySQL 5.1 Reference Manual :: 21.4.4.2 Running within a Java Object

I want to be able to use a different username and password, but if I simply try changing the value "alice" or the password, it gives me the following error:

com.mysql.management.util.SQLRuntimeException: User initialization error. Can not connect as alices with password. Can not connect as root without password.

Does anyone know if it's possible to set up new user and password directly through Java, or what other ways can i go about setting it up such that i can pack it along with my java application?

Thank you!
Reply With Quote
  #2 (permalink)  
Old 10-04-10, 03:23
it-iss.com it-iss.com is offline
Registered User
 
Join Date: Sep 2009
Location: San Sebastian, Spain
Posts: 620
Silly question here but does the new user you are trying with exist on the database server and has access to the database you are trying to access? The error message appears to be attempting a connection with the user alices, this fails and then is attempting another connection with the root user. Can you post up the code or is it identical to the one provided in the link?
__________________
Ronan Cashell
Senior Oracle/MySQL DBA
http://www.it-iss.com
Reply With Quote
  #3 (permalink)  
Old 10-04-10, 11:07
honeywish honeywish is offline
Registered User
 
Join Date: Oct 2010
Posts: 3
my code is exactly the same as the one provided in the link, and i'm using the mxj connector as an external library.

The problem is using the username "alice" and the password given in the example works, but if i try other username and password combination it doesn't work.

I'm not sure whether it's because the username and password is preconfigured into the mxj connector .jar file, because I do also have mySQL installed and set up on my computer but never added the user "alice" and it doesn't exist under my list of user.

I tried using "root" and empty password as well, and "root" with the password that I access the installed mySQL with but neither works.
Reply With Quote
  #4 (permalink)  
Old 10-04-10, 15:56
it-iss.com it-iss.com is offline
Registered User
 
Join Date: Sep 2009
Location: San Sebastian, Spain
Posts: 620
Hi,

I would look into the class MysqldResource because the function startDatabase appears to be using the username and password to return a connection.

I have found this mentioned in a document:

Quote:
Starting with Connector/MXJ 5.0.6 you can use the initialize-user property to a connection string. If set to true, the default an- onymous and root users will be removed and the user/password combination from the connection URL will be used to create a new user. For example:
Code:
String url = "jdbc:mysql:mxj://localhost:" + port + "/alice_db" + "?server.datadir=" + dataDir.getPath() + "&server.initialize-user=true"
+ "&createDatabaseIfNotExist=true" ;
__________________
Ronan Cashell
Senior Oracle/MySQL DBA
http://www.it-iss.com
Reply With Quote
  #5 (permalink)  
Old 10-04-10, 16:14
honeywish honeywish is offline
Registered User
 
Join Date: Oct 2010
Posts: 3
Hi,

thanks for the reply~

I saw that in the document too, but even though i've tried setting the initialize-user property to true, it still won't take the username and password i'm giving it and still returns the user initialization error...
Reply With Quote
Reply

Tags
connector, create, embedded, mjx, user

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On