Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2010
    Posts
    3

    Unanswered: 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!

  2. #2
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    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
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

  3. #3
    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.

  4. #4
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    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:

    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
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

  5. #5
    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...

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •