hi,

i wnat to copy one database from one server to other server using PHP script.

have do it on same server. but it could not work with difreent server

    Why not just dump the database, copy the dump to the new server, and load it there?

      Use phpMyAdmin. You will most likely have it on both servers, and it gives you a variety of output options, but the best option is to use SQL output, and then just import it back in on the new server.

        Hi
        thnx for suggestion

        but i want to transfer using my script

        coz wen my client make wrong chagne to database then how sholud i know from were it take wrong effect

        in this case if i have script which take clone of db then i can rollback it for client.

        n no need to run the script n all that

          Try that post again; your English is breaking up.

            hi,

            i dont watn to make dump using export of phpmyadmin

            i want to copy database from one server to another server with user permission seting

              If you don't want to use phpMyAdmin to do it then you have to use other software. MySQL isn't like a Microshaft Access database in that you can just copy a file. MySQL often has several files that make up a single database, and copying them to a new location is no guarantee of it working.

              Can you give a bit more detail, like, where you are trying to copy to? Is it a remote server, or one on the same network. Does it have a version of that database on already? Is either system in use currently?

                hi

                i dont want to use ny of software to copy.

                wen i transfer data using php script on same server it was work fine.

                but wen i wrote the code for both diffrent servver and diffrent user it can not work.

                here is code :

                <?php

                $connect2 = mysql_connect("localhost1","user1","pwd1");

                /$query = "CREATE DATABASE newsqldb25";
                $result = mysql_query($query);
                echo "db Create";
                /

                $database1="newsqldb25"; // destination
                $link1= mysql_select_db( $database1, $connect2 );

                set_time_limit(0);

                $database = 'mysqldb15'; //org
                $connect= mysql_connect("localhost2","user2","pwd2");   

                $link2= mysql_select_db( $database, $connect );

                $j=0;
                $tables = mysql_list_tables( $database , $connect);
                
                while( $line = mysql_fetch_row( $tables ) )
                {
                
                    $fields = mysql_list_fields( $database, $line[0], $connect );
                    $columns = mysql_num_fields( $fields );
                	$tab=$line[0];
                
                
                	mysql_query("DROP TABLE IF EXISTS newsqldb25.$tab");
                	mysql_query("CREATE TABLE newsqldb25.$tab LIKE mysqldb15.$tab")  or die(mysql_error());
                	mysql_query("INSERT INTO newsqldb25.$tab SELECT * FROM mysqldb15.$tab") ;
                
                    echo "Table: <b>".$line[0]."  </b>Done<br>";
                
                
                	 //echo "Total Field: <b>".$columns."</b><br>";
                
                }

                // echo "<br><br><br>";

                ?>

                  Well, I think I identified your problem. Is Apache (I'll assume Apache here) aware of what localhost1 and localhost2 is? Have you tried using the IP address instead?

                    hi

                    ya i wrote my IP for it.

                    but it give me error like :
                    newsqldb25 @localhost1 doesnt have accessed. access denied for user user1

                      Have you opened up the server to allow access to the database from an external connection? MySQL could be set up not to allow access from external connections. Also, the user you are specifying, do they have access to it?

                        hi

                        let me explain wat i understand

                        in my both server i have to give access for external user ?

                        ok??????

                          yes, you have to give access to external users for MySQL. This is not enabled by default as far as I am aware.

                            Write a Reply...