how to upload mysql database to my serverspace in programming

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neelsbr
    New Member
    • Jun 2010
    • 16

    how to upload mysql database to my serverspace in programming

    how to upload mysql database to my server space (hostgator,blue host) in programming method.any one can help me to do this.


    Thanks in Advance
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    mysqldump to produce a SQL file
    FTP the SQL file.
    Run the SQL on the server space

    Comment

    • neelsbr
      New Member
      • Jun 2010
      • 16

      #3
      How to run sql in server space.suppose i runs ,if any changes to be done in my database

      Comment

      • code green
        Recognized Expert Top Contributor
        • Mar 2007
        • 1726

        #4
        You run files and maintain a database on a remote server the same as you would locally.
        The remote scripts can be run through a local browser or on a Cron/Sched Task remotely

        Comment

        • neelsbr
          New Member
          • Jun 2010
          • 16

          #5
          thanks for your reply.i am using select out file query export data in my local system and load data in file query to import data.i m connecting to server from my local system.load data infile query is not executing.data are not imported in my server database.but that load data infile query works in my local system.can you please help me .

          Thanks

          Comment

          • code green
            Recognized Expert Top Contributor
            • Mar 2007
            • 1726

            #6
            'Is not working' is not very helpful.
            There could be a multitude of reasons depending on your set-up.
            You need to check whayt erors are being returned

            Comment

            • neelsbr
              New Member
              • Jun 2010
              • 16

              #7
              no errors would returned.load data infile query is not working.i checked that.i give the correct path,where i stored the sql file.this is the path i given backup/$table[$i].sql.table name comes automatically it runs through the loop

              Comment

              • neelsbr
                New Member
                • Jun 2010
                • 16

                #8
                i find out the problem.i want to get the sql file from mysql/data/backup/table1.sql.My programs under( htdocs/test/test.php).htdoc s directory.Now please help me to access that file.If i can access that file then ,the query will work.

                Thanks

                Comment

                • code green
                  Recognized Expert Top Contributor
                  • Mar 2007
                  • 1726

                  #9
                  I don't understand which file you are trying to access or from where.
                  Do you mean you want to run test.php?
                  Or do you mean you want test.php to run the .sql file.

                  From where are you running these scripts, on the server itself or remotely.

                  Either way what do you mean by
                  Now please help me to access that file

                  Comment

                  • neelsbr
                    New Member
                    • Jun 2010
                    • 16

                    #10
                    I am running test.php to execute a sql file.i am running program in my local system.please help me to how to access that particular file in my local system. sql files comes under this path C:\xampp\mysql\ data\backup.i want access the sql file in the above path.i understand the problem .the path is not given correctly.
                    thank u

                    Comment

                    • code green
                      Recognized Expert Top Contributor
                      • Mar 2007
                      • 1726

                      #11
                      Please supply the code you are trying
                      running test.php to execute a sql file
                      and the errors being returned that report an incorrect path
                      the path is not given correctly

                      Comment

                      • neelsbr
                        New Member
                        • Jun 2010
                        • 16

                        #12
                        Code:
                        <?php
                         require_once('library/config.php');
                        
                        $dbHost = 'localhost';
                        $dbUser = 'username';
                        $dbPass = 'password';
                        $dbName = 'dbname';
                        
                        $today=date('Y/m/d');
                        
                        $table=array('m_couponbook','m_discount','m_grade','m_kart','m_member','m_nonmember','m_publicholiday','m_rate','m_staff','t_billing','t_billingpenalty','t_cancelbilling','t_couponissue','t_duplicateaccesscard','t_groupbilling','t_groupbooking','t_memberattendance','t_memberpayment','t_raceallocation','t_raceevent','t_raceparticipation','t_performance','t_sponsorshipregistration','t_staffattendance');
                         $count=count($table);
                        for($i=0;$i<$count;$i++)
                        {
                        
                        $backupFile = "backup/$table[$i].sql";
                        $query      = "SELECT * INTO OUTFILE '$backupFile' FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' FROM `$table[$i]`";
                        $result = dbQuery($query);
                        
                        }
                        
                        /*$backupFile = $dbName . date("Y-m-d-H-i-s")  .'.gz';;
                        echo $command = "mysqldump --opt -h $dbHost -u $dbUser -p $dbPass $dbName | gzip > $backupFile";
                        system($command);*/
                        
                        // hostname or ip of server
                        $servername='box.bluehost.com';
                        
                        // username and password to log onto db server
                        $dbusername='username';
                        $dbpassword='password';
                        
                        // name of database
                        $dbname='dbname';
                        
                        ////////////// Do not  edit below/////////
                        
                        connecttodb($servername,$dbname,$dbusername,$dbpassword);
                        function connecttodb($servername,$dbname,$dbuser,$dbpassword)
                        {
                        global $link;
                        $link=mysql_connect ("$servername","$dbuser","$dbpassword");
                        if(!$link){die("Could not connect to MySQL");}
                        mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
                        }
                        
                        for($i=0;$i<$count;$i++)
                        {
                        $sql="TRUNCATE TABLE `$table[$i]`";
                        $res=mysql_query($sql);
                        
                        //$file = fopen("../mysql/data/backup/$table[$i].sql","r")or exit("Unable to open file!");
                        
                        //some code to be executed
                        //here i am getting sql files.this path has to be correct
                        echo $backupFile = "../backup/$table[$i].sql";
                        
                        $load="LOAD DATA INFILE '$file' INTO TABLE `$table[$i]` FIELDS TERMINATED BY ','";
                        echo $result=mysql_query($load);
                        //fclose($file);
                        }
                        //passthru("nohup mysql -u $dbusername -p $dbpassword $dbname < $backupFile");
                        echo "success";
                        
                        ?>
                        this code i am using.i didn't get any error message for path not given correctly.i understood the path was not given correctly .so that only its not working .i already given the path,where my sql file stored.how can i access the files.
                        Last edited by Niheel; Sep 29 '10, 07:35 AM.

                        Comment

                        • code green
                          Recognized Expert Top Contributor
                          • Mar 2007
                          • 1726

                          #13
                          I honestly don't understand your problem.
                          .i understood the path was not given correctly
                          If you know the path is wrong why don't correct it?
                          how can i access the files
                          Which files where?

                          I am guessing the SQL file is not being found, but then there would be an error message...
                          Try using full paths rather than relative

                          Comment

                          Working...