1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

how to transfer localhost mysql database to domain server database ????

Discussion in 'PHP' started by dineshsingh1984, Dec 7, 2014.

  1. #1
    I'm develop a web application where in warehouse work on localhost projects(web application) and here internet is not stable. so i want that if internet connection is available then localhost mysqldata is transfer in domain mysql database in a fix time interval.
    I'm using cron function but it's not working.
    plz tell me how can transfer the data local to domain database in a time interval....................

    plz help me..............
     
    Last edited: Dec 7, 2014
    dineshsingh1984, Dec 7, 2014 IP
  2. etc

    etc Well-Known Member

    Messages:
    3,232
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    158
    #2
    dyou mean for the local network to view/share or simply to deploy the app online? if its the later, you could just import the database to your host server. assuming you already have a domain and a host..

    inside the phpmyadmin, you can import your database.
     
    Last edited: Dec 7, 2014
    etc, Dec 7, 2014 IP
  3. dineshsingh1984

    dineshsingh1984 Active Member

    Messages:
    154
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #3
    thanks for reply...
    but i don't want import every hour the database. i want a script where every hour localhost data transfer to domain database...
    because it's a routin work. and no body spend the time every hour
     
    dineshsingh1984, Dec 7, 2014 IP
  4. etc

    etc Well-Known Member

    Messages:
    3,232
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    158
    #4
    once its imported, they can use it there an that it will be updated every now and then so no importing is going to happen every hour.
     
    etc, Dec 8, 2014 IP
  5. pmf123

    pmf123 Notable Member

    Messages:
    1,447
    Likes Received:
    75
    Best Answers:
    0
    Trophy Points:
    215
    #5
    i think they are looking for a cron job to make a local copy of the mysql server... not sure if they want to send it to the internet, or get it from the internet though
     
    pmf123, Dec 29, 2014 IP
  6. JEET

    JEET Notable Member

    Messages:
    3,825
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #6
    I did something like this long time ago for a site of mine.
    I made a php script which checked the database on specified time interval . The records that were created or modified during that hour were stored in a file like regular mysql queries.
    ex:

    insert into table (all values here);
    insert into table (all values here);
    and so on.

    when this file was complete, the php script would upload this file to the server using ftp.
    A cron job on the server would pass this file to the mysql using shell.

    I don't know if you have access to shell or not. If not, then you can use your localhost php script to connect to your mysql server on your webhost and run the query like regular php scripts do.
    It'll take longer, and you'll have to handle multiple connections.
     
    JEET, Dec 29, 2014 IP
  7. webshore88

    webshore88 Well-Known Member

    Messages:
    130
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    123
    #7
    Well it might be possible but it is little tricky. I will explain you in steps.

    1) Insert two fields in the table created_at, updated_at and set their data type as timestamp. Update these fields when you insert/update data.

    2) Enable CURL on your localhost and use this code.
    http://www.techsirius.com/2012/11/get-page-data-through-curl.html

    3) Setup CRON like system on your localhost using this link
    http://stackoverflow.com/questions/24035090/run-cron-job-on-php-script-on-localhost-in-windows

    4) Create a script for localhost that check every table in DB one by one if is there any new data row(updated_at, created_at).
    If yes fetch all rows and send them to server using CURL(Step 2)

    5) Create a script for server that receive data from localhost and insert/update data into database.

    Once localhost cron trigger the script DB synchronization will start working.
    I hope this would help you. If you have any question please let me know.
     
    webshore88, Jan 4, 2015 IP
  8. Pigeon Yoga

    Pigeon Yoga Active Member

    Messages:
    52
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    63
    #8
    Are you trying to pull the domain MySQL DB to your local computer with cron, or the other way around?
     
    Pigeon Yoga, Jan 4, 2015 IP
  9. ezprint2008

    ezprint2008 Well-Known Member

    Messages:
    611
    Likes Received:
    15
    Best Answers:
    2
    Trophy Points:
    140
    Digital Goods:
    1
    #9
    export localhost database to txt file ...then import to online database.
     
    ezprint2008, Jan 12, 2015 IP