replication between xampp localhost database and remote server database - php

I need to create replication between two different databases one is localhost database as the master and the second one is the remote server database as slave?
I have a codeigniter web application which is installed on both servers now I want to do that if the internet is not connected all application data should be saved in localhost database, when internet is connected all databases should be copied to the remote server database.
Is there any way I can attain this using localhost phpmyadmin or PHP scripts?
LocalHost Master Setting
How Do I Create Remote Server As Slave

Simple way would be to set up mysql replication. You could set up local mysql server as master and remote server as slave, so that all changes would automatically replicate from localhost to remote host. You also must be able to open mysql port on the remote server to listen to your local machine.
Here would be a basic tutorial: https://www.digitalocean.com/community/tutorials/how-to-set-up-master-slave-replication-in-mysql

Related

Two servers can't communicate via MySQL Error Code(110)

I have a web server that I can manage via cPanel and I'm trying to connect to a MySql database on a dedicated server (running Ubuntu Server) that I manage. I have two tester connections that give the same error code (from web server to dedicated server).
CDbConnection failed to open the DB connection: SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'IP_ADDRESS' (110)
Can't connect to MySQL server on 'IP_ADDRESS' (110)
I also tried on my computer to connect to the dedicated server and I can do it. I'm using HeidiSQL as a GUI client to try connecting and I can connect to it with the same credentials.
What I have tried:
(I'm using Webmin to manage my mysql server)
Set user host to Any
Checked my.cnf for a bind address and it is bound to 0.0.0.0(all ips)
Checked host permissions for specific databases and set the database to my test user and Any for hosts
The Iptable should just allow all because after installing Ubuntu Server I have not changed anything.
I have no idea what else to try.

Can not connect to my mysql database

I have been recently using "localhost" as my mysql database, and now i want to update my website to web.
I took free hosting at "serversfree.com" and uploaded all my web files there.Now i have problem.I made mysql database on that website, and uploaded my mysql database from localhost.
I can go to that server and list all files i have in that mysql database, but when i want to connect my .php documents i don't know how.What to put under "hostname" (i was recently using only localhost).Do i need to put a link where my web mysql database is?
Or i need to put a link where my website is?
I tried both but didn't worked for me
Most web hosts I've used have MySQL running on the same box so I usually can keep localhost as the server.
Your host should have some documentation on where to point the server to.
Check if your database credentials, are from a valid user in that database..
What hostname did you use to upload your mysql database from localhost? It would be the same hostname. Probably mysql.serversfree.com. If their mysql server is on the same subdomain then you can use localhost as well. To connect your php scripts to a mysql server you need to use the hostname of the mysql server, not the hostname of your http server.
If your mysql is running in the same server then you can use localhost or 127.0.0.1 but if mysql is in another server probably you need remote connections

Cannot connect to mysql database on remote host

I am not sure if the terms I am using are correct so ask for clarification if you need :).
Anyways, I am hosting through HostEasySolutions (Server A). It comes with a MySql database, using PHPMyAdmin as the frontend. On Server A, I added some PHP files to access the database, and it works fine.
If I copy the php files to my other server, through DreamHost (Server B), I cannot connect to the database. I get the error: Can't connect to MySQL server on 'combinedsystems.ca' (110)
In the cPanel on Server A, I added the IP for Server B into the Remote Database Access Hosts, I also just added the wildcard '%', just to see if I could get it working...but still it can't find the server.
I am not sure what is going on, as far as I can see there is no firewall.
The only thing that stands out to me, is that if I go to PHPmyAdmin for Server A, it says Server: Localhost via UNIX socket, where as for Server B's PHPMyAdmin, it says: Server: mysql.pdem.info via TCP/IP
Most (all?) hosting companies have port 3306 closed on the firewall.
What you need to do:
adding remote database access in the database
edit my.cnf to listen on all interfaces. Default mysql listens only to localhost
most of the time you are out of luck! Even if there is no firewall (would be very unsecure) you have no access to my.cnf

apache/php/mysqli connection to remote db fails but IIS and MySQL workbench connects

I am developing locally and connecting to a remote mysql server. I had been using IIS on my local machine (WinXP) but am now using Apache instead. Most of my PHP site is working correctly after the move to Apache.
But - when mysqli tries to connect to the remote db I get:
(HY000/2003): Can't connect to MySQL server on '...:**' (10060)
I know that the server is accepting connections from my IP because I am able to connect to the same server from my local machine using MySQL Workbench.
I also know that the db connection details I'm using with mysqli are correct because I was using the same details when running on IIS without problem, the only change that happened is that I moved from IIS to Apache.
This problem still exists when my local firewall is disabled.
I have very little experience with Apache, is there perhaps a config setting I've missed that prevents me from connecting out to a remote db, or something that is mangling/hiding reporting of my correct IP?
Thanks for any help, I'm clutching at straws here...
Error 10060 happens when the remote MySQL server does not respond.
It could be that connections to port 3306 on the remote machine are being blocked. It could be that the system hosting PHP/Apache has a software firewall that is blocking the outgoing connection, or that PHP/Apache is not permitted to open network connections by that firewall.

How can I connect to MySQL database on a dedicated Windows 2003 server from EC2 based app server with PHP

I have developed a web application that uses PHP and MySQL and has all been running fine from a single development server. I now want to separate things a bit and place an app server within Amazons cloud that will receive and process uploaded files. The database is going to remain on the dedicated server but will need to be accessed by the EC2 instance.
Heres what I have tried so far...
In phpMyAdmin I added a new user to the privileges table. I gave it the elastic IP address from AWS as the host name, a new password and granted privileges to INSERT, SELECT and UPDATE.
In the PHP scripts on my EC2 based app server I included this username, password and the domain name of the location of the mysql server (example.domain.net) when connecting with mysql_connect
I have a simple test page that tries to SELECT and echo some results from the database but get the following error -
Could not connect to MySQL: Can't connect to MySQL server on 'example.domain.net' (4)
What could this mean, what have I missed, are there any other issues such as trying to do this from within EC2 that will cause other problems?
cheers all
Turns out the only other thing I needed to do was to open port 3306 on the database server to allow access. Did this by going to Control Panel -> Windows Firewall -> Exceptions -> Add Port ["SQL", 3306]
Now it works great!

Categories