Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6542581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:14:42+00:00 2026-05-25T11:14:42+00:00

I’m a noob, is there someone could help me with this? I have a

  • 0

I’m a noob, is there someone could help me with this?

I have a local SQL database using Xampp thru phpMyAdmin and i want to mirror it to online MySQL in my website.

When I’m making changes to my local database, I want my online database to be updated (Realtime) with the changes made.

Is this possible? Can I have a sample php code or whatever that can do this? Thanks!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:14:42+00:00Added an answer on May 25, 2026 at 11:14 am

    Many times ago I wrote some script for this problem. As said above – replication it’s really good solution but in my case I could not use it. So.. if you need some like replication by master->slave maybe this script will be useffull :

    dumps.sh : 
    while getopts "c:l:" opt; do
            case $opt in
                    c)
                    if [ -r "$OPTARG" ]; then
                                    source "$OPTARG"
                            else
                                    echo "Unreadable config file \"$OPTARG\""
                                    exit 1
                            fi
                            ;;
                    l) LOG_FILE="$OPTARG"
                            if [ ! -f "$LOG_FILE" ]; then
                                    `touch $LOG_FILE`
                            fi
                            ;;
                    \?) echo "Invalid options. -$OPTARG. USE -c config_file"
                            exit 1
                            ;;
                     :) "Option -$OPTARG requires an argument."
                            ;;
            esac
    done
    
    logIt()
    {
            date_now=`date '+%D %T'`
            if [ $LOG_FILE != "" ]; then
                    echo "$date_now : $*" >> $LOG_FILE
            else
                    echo "$date_now : $*"
            fi
    }
    
    build_tables()
    {
            TAB=""
            logIt $@
            for table in $TABLES
            do
                    TAB="$TAB ${1}${table}"
            done
            echo $TAB
    }
    MYSQLDUMP="$(which mysqldump)"
    CHOWN="$(which chown)"
    CHMOD="$(which chmod)"
    GZIP="$(which gzip)"
    RM="$(which rm)"
    DEST="."
    
    MBD="$DEST/mysql"
    eval $RM -fv "$MBD/*"
    FILE=""
    
    [ ! -d $MBD ] && mkdir -p $MBD || :
    
    $CHOWN 0.0 -R $DEST
    $CHMOD 0600 $DEST
    
    TAB=`build_tables $DB_PREFIX`
    
    FILE="$MBD/$DB_NAME.sql";
    ($MYSQLDUMP -u $MyUSER -h $MyHOST -p$MyPASS $DB_NAME $TAB  2>> $LOG_FILE) > $FILE
    
    
    input_to_mysql()
    {
            ###############################3
            CP="$(which cp)"
            SED="$(which sed)"
            len=${#INSERT_DB_NAME[*]}
            i=0
    
            while [ $i -lt $len ]; do
                    NEW_FILE="$MBD/${INSERT_DB_NAME[$i]}.sql"
                    eval $CP $FILE $NEW_FILE
                    eval $SED -i "s/$DB_PREFIX/${INSERT_DB_PREFIX[$i]}/g" $NEW_FILE
                    eval $SED -i "s/^.\*!.*$//g" $NEW_FILE
                    let i++
            done
            i=0
            while [ $i -lt $len ]; do
                    NAME="$MBD/${INSERT_DB_NAME[$i]}.sql"
                    if [ -e $NAME ]; then
                                    $MYSQL -u${INSERT_DB_USER[$i]} -p${INSERT_DB_PASS[$i]} -h${INSERT_DB_HOST[$i]} ${INSERT_DB_NAME[$i]} < $NAME 2>> $LOG_FILE
                                    #echo "$MYSQL -u${INSERT_DB_USER[$i]} -p${INSERT_DB_PASS[$i]} -h${INSERT_DB_HOST[$i]} ${INSERT_DB_NAME[$i]} < $NAME"
                                    logIt "IMPORT TO ${INSERT_DB_NAME[$i]}"
                    else
                            logIt "File $NAME not exist";
                    fi
                    let i++
            done
    }
    
    check_dump()
    {
            FILE_TMP_DUMP="$MBD/tmp_dump_${INSERT_DB_NAME[0]}.sql";
            FILE_DIFF_RESS="$MBD/diff_res.diff"
            tmp_tables=`build_tables ${INSERT_DB_PREFIX[0]}`
            ($MYSQLDUMP -u ${INSERT_DB_USER[0]} -h ${INSERT_DB_HOST[0]} -p${INSERT_DB_PASS[0]} ${INSERT_DB_NAME[0]} $tmp_tables 2>>$LOG_FILE) > $FILE_TMP_DUMP
            DIFF="$(which diff)"
            $DIFF $FILE $FILE_TMP_DUMP > FILE_DIFF_RESS
            [ -s "$SMB/diff_res.diff" ];
            SUCCESS=$?
            eval $RM -f $FILE_TMP_DUMP $FILE_DIFF_RESS
            return $SUCCESS
    }
    
    if check_dump; then
            input_to_mysql
    else
            logIt "No need to dump"
    fi
    

    so run like dump.sh -c config -l log.file

    Where config like this:

    MyHOST="master_host"
    MyUSER="master_user"
    MyPASS="master_password"
    DB_NAME="master_db_name"
    DB_PREFIX="master_db_prefix_" # leave empty if you haven't table prefix
    
    TABLES="table1 table2 table3" // list of tables - leave empty for all tables
    
    
    ###############################
    INSERT_DB_NAME=(slave_dbname1 slave_dbname2)
    INSERT_DB_HOST=(slave_host1 slave_host2)
    INSERT_DB_USER=(slave_user1 slave_user2)
    INSERT_DB_PASS=(slave_pass1 slave_pass2)
    INSERT_DB_PREFIX=(slave_db_prefix1 slave_db_prefix1) //
    

    I putted it to cron and all works fine for me.
    Of course you can do all this manually …

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have thousands of HTML files to process using Groovy/Java and I need to
I have a reasonable size flat file database of text documents mostly saved in
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.