Connection to database on different server

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

Connection to database on different server

Postby Vadrox » 18. February 2014 11:53

Sieg Hallo Leute,

I've been trying to connect to a database running on a different computer. No luck so far. all I get is this error
Code: Select all
#2002 Can not connect because the target machine actively refused it.


ive tried to:
- in httpd-xampp-conf, add allow from all and allow from <ip>
- changed the listen / host adress in my.ini & config.inc.php
- changed
$cfg['Servers'][$i]['controluser'] = '$pma';
to
$cfg['Servers'][$i]['controluser'] = '$root';


I dont know if i missed something but its abviously not working right now. Can anyone help me out?

Thanks in advance.
Vadrox
 
Posts: 7
Joined: 18. February 2014 11:32
Operating System: Winfows 7

Re: Connection to database on different server

Postby Nobbie » 18. February 2014 12:04

a) This is the german board (see above "Xampp auf Deutsch"!)

b) we need to know all credentials for the remote server. That means servername, username and password. And we need a screen shot of a running PhpMyadmin on that server, in order to see if you applied the right credentials in your local script.

c) Is it a remote server inside your LAN, or is it a remote server in the WWW?

ive tried to:
- in httpd-xampp-conf, add allow from all and allow from <ip>
- changed the listen / host adress in my.ini & config.inc.php


Thats useless. It is not a question of apache, it is a question of the mysql client and mysql server. You have to find out, if the local mysql client my connect to the remote mysql server (that does not have anything to do with Apache).
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: Connection to database on different server

Postby Vadrox » 18. February 2014 12:40

a) This is the german board (see above "Xampp auf Deutsch"!)

Oh.. haha well lets just pretend we're in the english section then.

b) we need to know all credentials for the remote server. That means servername, username and password. And we need a screen shot of a running PhpMyadmin on that server, in order to see if you applied the right credentials in your local script.


Servername,username and password are all default xampp setting. no harm done to that.

PphMyadming runs fine on the computer it runs on.
Note: we run xampp form a shared disk. pc1 runs apache and mySql and pc2(my pc) runs apache. If i dont run apache the the xampp interface is just not accesible. However, i can't run MySql if the other pc has it running.

in Xampp status it says that the mysql database in deactivated(on my pc) if that matters to this case.

c) Is it a remote server inside your LAN, or is it a remote server in the WWW?

Its a server in my LAN.

Below you will find some configs not sure if its all you need but just let me know.


Image
Image
Code: Select all
# Example MySQL config file for small systems.
#
# This is for a system with little memory (<= 64M) where MySQL is only used
# from time to time and it's important that the mysqld daemon
# doesn't use much resources.
#
# You can copy this file to
# Z:/xampp-win32-1.8.2-2-VC9/xampp/mysql/bin/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is Z:/xampp-win32-1.8.2-2-VC9/xampp/mysql/data) or
# ~/.my.cnf to set user-specific options.
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.

# The following options will be passed to all MySQL clients
[client]
# password       = your_password
port            = 3306
socket          = "Z:/xampp-win32-1.8.2-2-VC9/xampp/mysql/mysql.sock"


# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port= 3306
socket = "Z:/xampp-win32-1.8.2-2-VC9/xampp/mysql/mysql.sock"
basedir = "Z:/xampp-win32-1.8.2-2-VC9/xampp/mysql"
tmpdir = "Z:/xampp-win32-1.8.2-2-VC9/xampp/tmp"
datadir = "Z:/xampp-win32-1.8.2-2-VC9/xampp/mysql/data"
pid_file = "mysql.pid"
# enable-named-pipe
key_buffer = 16M
max_allowed_packet = 1M
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
log_error = "mysql_error.log"

# Change here for bind listening
# bind-address="127.0.0.1"
# bind-address = ::1          # for ipv6

# Where do all the plugins live
plugin_dir = "Z:/xampp-win32-1.8.2-2-VC9/xampp/mysql/lib/plugin/"

# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
#
# commented in by lampp security
#skip-networking
skip-federated

# Replication Master Server (default)
# binary logging is required for replication
# log-bin deactivated by default since XAMPP 1.4.11
#log-bin=mysql-bin

# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id   = 1

# Replication Slave (comment out master section to use this)
#
# To configure this host as a replication slave, you can choose between
# two methods :
#
# 1) Use the CHANGE MASTER TO command (fully described in our manual) -
#    the syntax is:
#
#    CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,
#    MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
#
#    where you replace <host>, <user>, <password> by quoted strings and
#    <port> by the master's port number (3306 by default).
#
#    Example:
#
#    CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
#    MASTER_USER='joe', MASTER_PASSWORD='secret';
#
# OR
#
# 2) Set the variables below. However, in case you choose this method, then
#    start replication for the first time (even unsuccessfully, for example
#    if you mistyped the password in master-password and the slave fails to
#    connect), the slave will create a master.info file, and any later
#    change in this file to the variables' values below will be ignored and
#    overridden by the content of the master.info file, unless you shutdown
#    the slave server, delete master.info and restart the slaver server.
#    For that reason, you may want to leave the lines below untouched
#    (commented) and instead use CHANGE MASTER TO (see above)
#
# required unique id between 2 and 2^32 - 1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
#server-id       = 2
#
# The replication master for this slave - required
#master-host     =   <hostname>
#
# The username the slave will use for authentication when connecting
# to the master - required
#master-user     =   <username>
#
# The password the slave will authenticate with when connecting to
# the master - required
#master-password =   <password>
#
# The port the master is listening on.
# optional - defaults to 3306
#master-port     =  <port>
#
# binary logging - not required for slaves, but recommended
#log-bin=mysql-bin


# Point the following paths to different dedicated disks
#tmpdir = "Z:/xampp-win32-1.8.2-2-VC9/xampp/tmp"
#log-update = /path-to-dedicated-directory/hostname

# Uncomment the following if you are using BDB tables
#bdb_cache_size = 4M
#bdb_max_lock = 10000

# Comment the following if you are using InnoDB tables
#skip-innodb
innodb_data_home_dir = "Z:/xampp-win32-1.8.2-2-VC9/xampp/mysql/data"
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = "Z:/xampp-win32-1.8.2-2-VC9/xampp/mysql/data"
#innodb_log_arch_dir = "Z:/xampp-win32-1.8.2-2-VC9/xampp/mysql/data"
## You can set .._buffer_pool_size up to 50 - 80 %
## of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 16M
innodb_additional_mem_pool_size = 2M
## Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

## UTF 8 Settings
#init-connect=\'SET NAMES utf8\'
#collation_server=utf8_unicode_ci
#character_set_server=utf8
#skip-character-set-client-handshake
#character_sets-dir="Z:/xampp-win32-1.8.2-2-VC9/xampp/mysql/share/charsets"

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[isamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M

[myisamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout
Vadrox
 
Posts: 7
Joined: 18. February 2014 11:32
Operating System: Winfows 7

Re: Connection to database on different server

Postby Nobbie » 18. February 2014 13:02

Vadrox wrote:Servername,username and password are all default xampp setting. no harm done to that.


Ok, that already explains everything. Xampp does not come with a MySQL User that may enter MySQL from an external client ("root" is configured for localhost only). Therefore the connection is refused,
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: Connection to database on different server

Postby Vadrox » 18. February 2014 13:47

Well that clears up some things haha. Is there a way to add or edit users so i can connect to the database ? or is this just end of story?
Vadrox
 
Posts: 7
Joined: 18. February 2014 11:32
Operating System: Winfows 7

Re: Connection to database on different server

Postby Altrea » 18. February 2014 16:33

Simply add a new user for that specific host you want to connect from (or for any host but that is not recommend)
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Connection to database on different server

Postby Nobbie » 18. February 2014 16:38

Vadrox wrote:Is there a way to add or edit users so i can connect to the database ?


Of course, simply start PhpMyAdmin on the server, and add a new User. You have to apply a "Host" for the user, this means the PC, where the User wants to connect from. So you either enter the LAN IP of that PC or a valid Netname (the name of the PC in the Windows Network for example).

Grant ALL rights to this user, give him a password (dont forget that password) and thats it. Sometimes its a good idea to add the same user twice, one with the IP and the other with the Netname. You will find similar entries for "root" (for localhost, for 127.0.0.1) and so. Pay attention to give the same password to both entries.

Finally provide this new user (incl. password) to the script on the client PC, whicht wants to connect to the remote MySQL.
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: Connection to database on different server

Postby Vadrox » 19. February 2014 09:25

Correct me if i'm wrong,

I have to edit the host file in "C:\Windows\System32\drivers\etc" and what i have to do is add a new line / host with the IP and just a random name for that pc?

For example:

Code: Select all
# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1                 localhost
10.31.4.104            Workpc


Am i doing that right ?

Now for the new user in phpmyadmin:

I add a user where username = "desired username" and machine = (in this case) "Workpc" right?

Now i have to set a static IP for a workpc else i have to change the host file all the time. However.. i have to wait for IT to change the host file lol :cry: ..

*Edit: what do you mean with
the script on the client PC
?
Vadrox
 
Posts: 7
Joined: 18. February 2014 11:32
Operating System: Winfows 7

Re: Connection to database on different server

Postby Altrea » 19. February 2014 12:20

Vadrox wrote:Correct me if i'm wrong,

I have to edit the host file in "C:\Windows\System32\drivers\etc" and what i have to do is add a new line / host with the IP and just a random name for that pc?

No, that is not needed except your server is not able to resolve the computername workpc. If they are in the same subnet that is not a problem.

Vadrox wrote:I add a user where username = "desired username" and machine = (in this case) "Workpc" right?

I would add a user for the specific ip too, for the case the name resolution will not work
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Connection to database on different server

Postby Vadrox » 19. February 2014 12:29

I just figured out that a closed port (3306) might be the issue here. IT is on to it after lunch. I'll let you know.
Vadrox
 
Posts: 7
Joined: 18. February 2014 11:32
Operating System: Winfows 7

Re: Connection to database on different server

Postby Nobbie » 19. February 2014 13:30

Vadrox wrote:*Edit: what do you mean with
the script on the client PC
?


??

You asked for "connection to database on different server" - connection for "what"? Which program (= PHP Script?!) needs a "connection" to different server? This is meant by "script on the client PC" (because it is mostly a PHP Script).
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: Connection to database on different server

Postby Vadrox » 19. February 2014 13:47

everything is working fine now. Thanks for all the assistance! :)
Vadrox
 
Posts: 7
Joined: 18. February 2014 11:32
Operating System: Winfows 7

Re: Connection to database on different server

Postby Vadrox » 19. February 2014 13:49

You asked for "connection to database on different server" - connection for "what"? Which program (= PHP Script?!) needs a "connection" to different server? This is meant by "script on the client PC" (because it is mostly a PHP Script).


I know now what you meant. Here its in a class thats what confused me.
Vadrox
 
Posts: 7
Joined: 18. February 2014 11:32
Operating System: Winfows 7


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 109 guests