How to change mysql server name ?

Problems with the Windows version of XAMPP, questions, comments, and anything related.

How to change mysql server name ?

Postby budhik » 23. December 2008 13:45

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
budhik
 
Posts: 9
Joined: 23. December 2008 13:33

Re: How to change mysql server name ?

Postby Wiedmann » 23. December 2008 13:48

but fails if i use its IP address.

Why?
--> MySQL client lib error message/ error code
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: How to change mysql server name ?

Postby budhik » 23. December 2008 14:00

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 ?
budhik
 
Posts: 9
Joined: 23. December 2008 13:33

Re: How to change mysql server name ?

Postby Wiedmann » 23. December 2008 14:06

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.)
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: How to change mysql server name ?

Postby budhik » 23. December 2008 14:12

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)
budhik
 
Posts: 9
Joined: 23. December 2008 13:33

Re: How to change mysql server name ?

Postby Wiedmann » 23. December 2008 14:14

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.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: How to change mysql server name ?

Postby budhik » 23. December 2008 14:18

How to do that ? sorry, I always use phpmyadmin... :(
budhik
 
Posts: 9
Joined: 23. December 2008 13:33

Re: How to change mysql server name ?

Postby Wiedmann » 23. December 2008 14:26

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
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: How to change mysql server name ?

Postby budhik » 23. December 2008 14:28

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 ?
budhik
 
Posts: 9
Joined: 23. December 2008 13:33

Re: How to change mysql server name ?

Postby budhik » 23. December 2008 14:30

I re-login using :

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

and it shows OK

mysql>

what's next step ?
budhik
 
Posts: 9
Joined: 23. December 2008 13:33

Re: How to change mysql server name ?

Postby Wiedmann » 23. December 2008 14:36

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?
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: How to change mysql server name ?

Postby budhik » 23. December 2008 14:42

No... that's from windows command box...
budhik
 
Posts: 9
Joined: 23. December 2008 13:33

Re: How to change mysql server name ?

Postby budhik » 23. December 2008 14:45

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.
budhik
 
Posts: 9
Joined: 23. December 2008 13:33

Re: How to change mysql server name ?

Postby budhik » 23. December 2008 14:56

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... :(
budhik
 
Posts: 9
Joined: 23. December 2008 13:33

Re: How to change mysql server name ?

Postby Wiedmann » 23. December 2008 14:57

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.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 57 guests