Page 1 of 1

How to change mysql server name ?

PostPosted: 23. December 2008 13:45
by budhik
Hi,

I used XAMPP for windows 1.6.7 to installed mysql. The IP address of the machine is 140.135.100.180.
I developed Java application that access mysql. Previously it works well with "localhost" or "127.0.0.1" calling. When I start to distribute my application, I have change it to "140.135.100.180" to call mysql. But the application can not reach the mysql database. It runs well if I use "localhost" or "127.0.0.1" but fails if i use its IP address.

I think I should change the database server name from "localhost" to "140.135.100.180". But I can not find my.ini or my.cnf files in XAMPP installation files. How to solve this problem ?

Budhi

Re: How to change mysql server name ?

PostPosted: 23. December 2008 13:48
by Wiedmann
but fails if i use its IP address.

Why?
--> MySQL client lib error message/ error code

Re: How to change mysql server name ?

PostPosted: 23. December 2008 14:00
by budhik
I found this error code from my NetBeans IDE :

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

But, if I change to "localhost" or "127.0.0.1", the Java application can runs well. But since I have to distribute that application, I have to change the call into mysql's IP address. And that error is the result. What should I do ?

Re: How to change mysql server name ?

PostPosted: 23. December 2008 14:06
by Wiedmann
Can you make a connection from the same client with the MySQL command line tool to this ip? (Maybe we have a better error message then.)

Re: How to change mysql server name ?

PostPosted: 23. December 2008 14:12
by budhik
how to do that ?

I tried to write :

C:\xampp\mysql\bin\mysql

But there is an error :

ERROR 1045 (28000) : Access denied for user "ODBC"@"localhost" (using password : NO)

Re: How to change mysql server name ?

PostPosted: 23. December 2008 14:14
by Wiedmann
Right, you must also use the parameters for username/password (same as in your java code) and of course the ip you want connect to.

Re: How to change mysql server name ?

PostPosted: 23. December 2008 14:18
by budhik
How to do that ? sorry, I always use phpmyadmin... :(

Re: How to change mysql server name ?

PostPosted: 23. December 2008 14:26
by Wiedmann
I always use phpmyadmin...

Using a browser is a good idea:
http://dev.mysql.com/doc/refman/5.0/en/mysql.html

Like most other console tools you can also use "--help" as parameter for help.

How to do that ?

Code: Select all
mysql -h host -u user -p

Re: How to change mysql server name ?

PostPosted: 23. December 2008 14:28
by budhik
OK. I already login with this command :

shell>>mysql -u root -p "" dicom

And there are informations show :

database <no default value>
host <no default value>
etc...

What's next step ?

Re: How to change mysql server name ?

PostPosted: 23. December 2008 14:30
by budhik
I re-login using :

shell>>mysql -h 140.135.100.180 -u root -p

and it shows OK

mysql>

what's next step ?

Re: How to change mysql server name ?

PostPosted: 23. December 2008 14:36
by Wiedmann
shell>>mysql -h 140.135.100.180 -u root -p
and it shows OK

That's from the same box your Java code is also running?

Re: How to change mysql server name ?

PostPosted: 23. December 2008 14:42
by budhik
No... that's from windows command box...

Re: How to change mysql server name ?

PostPosted: 23. December 2008 14:45
by budhik
What do you mean with "box" ?
If you means I run in the same machine, the answer is YES. My Java application, mysql, and the code that I run in windows command box are run in the same machine.

Re: How to change mysql server name ?

PostPosted: 23. December 2008 14:56
by budhik
In the windows command box, i wrote :

mysql>select current_user();

and the result is :

root@140.135.100.180

It should be OK wright ? It looked like the user of "root" from 140.135.100.180 (which is my PC) can access the mysql database. Why the IP was rejected in Java ? Bellow is my java code to connect using JDBC :

String url = "jdbc:mysql://140.135.100.180:3306/dicom?jdbcCompliantTruncation=false";
Connection con;
con = DriverManager.getConnection(url, "root", "");

When it run, the error message occurs :

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

But if I change with "jdbc:mysql://localhost:3306/dicom" or "jdbc:mysql://127.0.0.1:3306/dicom", it runs well. It so confusing... :(

Re: How to change mysql server name ?

PostPosted: 23. December 2008 14:57
by Wiedmann
Well, so there is no problem connecting to this ip with the user you are also using in Java.

You should read and search the MySQL Forum "JDBC and Java"
I have seen they have some threads about your error message.