0

neethu@ubuntu:~$ mysqldump -u root -p database_name > /home/neethu/Desktop/time/backup5.sql
Enter password:
neethu@ubuntu:~$

this code works in terminal...but i need to implement it using php...

hi, i want to dump databases... we r doing a project on replication of databases.... through terminal replication works all well ... but in developing gui in netbeans using php im not able to dump databases using mysqldump...tried out many codes by googling but was of no use....is der any way out other than mysqldump...pls help...

neethu@ubuntu:~$ mysqldump -u root -p database_name > /home/neethu/Desktop/time/backup5.sql
Enter password:
neethu@ubuntu:~$

this code worked but through php i tried many codes but was of no use

$cmd = "$dump -u$username -p$password $data --quick --add-drop-table $db $t | $grep -v 'Dump completed' | $gzip -n > $temp";
                    system($cmd);

above is jus one among many dat i tries...pls help me asap...

awaiting ur reply...

Edited by nav33n: Use the snippet textbox to post your working and fully tested code snippet.

3
Contributors
28
Replies
29
Views
7 Years
Discussion Span
Last Post by lakshmi4788
0

Hello,

Assuming you have the variables set correctly and system is not disabled you need a space between the -u and $username but none after-p for $password. The grep for the message is not needed since it goes to the terminal screen and is not output to the file. And I suggest creating the file then gzip'ing it. Try something like this for your code:

$cmd = "$dump -u $username -p$password $data --quick --add-drop-table $db $t ; gzip $temp ";
                    system($cmd);
0

hi,
$cmd = "$dump -u $username -p$password $data --quick --add-drop-table $db $t ; gzip $temp ";

system($cmd);

but where do i mention the path where i need database to be dumped...

0

Opps forgot to add that part.

$cmd = "$dump -u $username -p$password $data --quick --add-drop-table $db $t  > $temp; gzip $temp ";

      system($cmd);
0
<?php




        // Change Me

    $username = "root";
    $password = "pass";
    $connect=mysql_connect("localhost","root","nandanam") or die("loser");
    $db= "jai";
    @mysql_select_db($db) or die( "Unable to select database");
    $temp="/home/lakshmi/Desktop/hanuman/backup5.sql ";


      $cmd = "$dump -u $username -p$password $data --quick --add-drop-table $db $t > $temp; gzip $temp ";


   
      system($cmd);
?>




        
    </body>
</html>

then clicked run , no error was shown but the database was not dumped...didnt serve my purpose....is der anything wrong in wht im doin????

Edited by nav33n: Use [code][/code] tags to wrap your code for easy readability.

0

<?php


// Change Me

$username = "root";
$password = "pass";
$connect=mysql_connect("localhost","root","nandanam") or die("loser");
$db= "jai";
@mysql_select_db($db) or die( "Unable to select database");
$temp="/home/lakshmi/Desktop/hanuman/backup5.sql ";


$cmd = "$dump -u $username -p$password $data --quick --add-drop-table $db $t > $temp; gzip $temp ";

system($cmd);
?>

</body>
</html>

then clicked run , no error was shown but the database was not dumped...didnt serve my purpose....is der anything wrong in wht im doin????

Well you never define $dump = mysqldump and what are $data and $t for?
And checking I found the following syntax through google which shows your original | to gzip:

<?php
include 'config.php';
include 'opendb.php';

$backupFile = $dbname . date("Y-m-d-H-i-s") . '.gz';
$command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $dbname | gzip > $backupFile";
system($command);
include 'closedb.php';
?>
0
<?php
         include 'config.php';
         include 'opendb.php';
       $backupFile = $dbname . date("Y-m-d-H-i-s") . '.gz';
        $command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $dbname | gzip > $backupFile";
         system($command);
         include 'closedb.php';
         ?>

in the code that u jus provided where is the path to dump the database...i tried the code... no error was der... but db was not dumped...

and in the code shown below

<?php
$username = "root";
$password = "pass";
$connect=mysql_connect("localhost","root","pass") or die("loser");
$db= "jai";
@mysql_select_db($db) or die( "Unable to select database");
$temp="/home/lakshmi/Desktop/hanuman/backup5.sql ";
$cmd = "$dump -u $username -p$password $data --quick --add-drop-table $db $t > $temp; gzip $temp ";
system($cmd);
?>

how to define $dump = mysqldump and what are $data and $t used for ?.....i need to dump a db to a particular folder in my desktop...

Edited by nav33n: Use [code][/code] tags.

0

Hi
try your code like this everything will works, I think it is not necessary to connect to DB.

$dbname = 'database_name';//your actual database name
$backupFile = '/home/lakshmi/Desktop/'.$dbname . date("Y-m-d-H-i-s") . '.gz';
$dbuser = 'root'; // mysql username
$dbpass = 'password'; // mysql password 
system("mysqldump -u $dbuser -p$dbpass --quick $dbname | gzip > $backupFile");
<?php
         include 'config.php';
         include 'opendb.php';
       $backupFile = $dbname . date("Y-m-d-H-i-s") . '.gz';
        $command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $dbname | gzip > $backupFile";
         system($command);
         include 'closedb.php';
         ?>

in the code that u jus provided where is the path to dump the database...i tried the code... no error was der... but db was not dumped...

and in the code shown below

<?php
$username = "root";
$password = "pass";
$connect=mysql_connect("localhost","root","pass") or die("loser");
$db= "jai";
@mysql_select_db($db) or die( "Unable to select database");
$temp="/home/lakshmi/Desktop/hanuman/backup5.sql ";
$cmd = "$dump -u $username -p$password $data --quick --add-drop-table $db $t > $temp; gzip $temp ";
system($cmd);
?>

how to define $dump = mysqldump and what are $data and $t used for ?.....i need to dump a db to a particular folder in my desktop...

Edited by saiprem: n/a

0

<?php

include 'config.php';

include 'opendb.php';

/*$backupFile = $dbname . date("Y-m-d-H-i-s") . '.gz';

$command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $dbname | gzip > $backupFile";

system($command);
*/

$dbname = 'jai';//your actual database name

$backupFile = '/home/lakshmi/Desktop/hanuman/'.$dbname . date("Y-m-d-H-i-s") . '.gz';

$dbuser = 'root'; // mysql username

$dbpass = 'nandanam'; // mysql password

system("mysqldump -u $dbuser -p$dbpass --quick $dbname | gzip > $backupFile");


include 'closedb.php';

?>

</body>
</html>
everything i jus as u said....but in vain...no db was dumped...i ran the code in netbeans....is der anythin else to be done other than the code n simply runnin it...

0

<?php

include 'config.php';

include 'opendb.php';

/*$backupFile = $dbname . date("Y-m-d-H-i-s") . '.gz';

$command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $dbname | gzip > $backupFile";

system($command);
*/

$dbname = 'jai';//your actual database name

$backupFile = '/home/lakshmi/Desktop/hanuman/'.$dbname . date("Y-m-d-H-i-s") . '.gz';

$dbuser = 'root'; // mysql username

$dbpass = 'nandanam'; // mysql password

system("mysqldump -u $dbuser -p$dbpass --quick $dbname | gzip > $backupFile");


include 'closedb.php';

?>

</body>
</html>
everything i jus as u said....but in vain...no db was dumped...i ran the code in netbeans....is der anythin else to be done other than the code n simply runnin it...

Take a look at the error logs.
It may be that the apache user does not have permission to write to the directory /home/lakshmi/Desktop/hanuman/

Can you get logged in via ssh and try the command from the command line? It may require full path to find mysqldump or something else. If you can connect with ssh try the following from the user prompt:

mysqldump -u root -pnandanam jai

It should output to the terminal. If it works then add

> /home/lakshmi/Desktop/hanuman/outfile.sql

and see if it creates the file. If that works stick the whole command line in the quotes and see what happens. I would like to know what it is when you figure it out.

0

Is your php program running in netbeans, please check that by putting general echo statements, if it is running check which DB(mysql, sqlite, mssql, oracle) you are using and which DB you are dumping.

If everything is working fine & all the settings are correct
then it might be something wrong with your code.

can you tell me which OS you are using.

If you are using Linux, you can directly type the following command in your linux shell prompt

ex:
linuxshell > mysqldump -u dbusername -pdbpassword --quick dbname | gzip > filepath_where_do_u_want_take_backup

If you are using windows platorm, check where mysql is installed go to mysql installed path and type the above shown command
(nothing but mysqldump.exe will be present in the mysql installed location)
ex:
D:\PHP\bin\mysql\mysql5.1.30\bin> mysqldump -u dbusername -pdbpassword --quick dbname | gzip > filepath_where_do_u_want_take_backup

<?php

include 'config.php';

include 'opendb.php';

/*$backupFile = $dbname . date("Y-m-d-H-i-s") . '.gz';

$command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $dbname | gzip > $backupFile";

system($command);
*/

$dbname = 'jai';//your actual database name

$backupFile = '/home/lakshmi/Desktop/hanuman/'.$dbname . date("Y-m-d-H-i-s") . '.gz';

$dbuser = 'root'; // mysql username

$dbpass = 'nandanam'; // mysql password

system("mysqldump -u $dbuser -p$dbpass --quick $dbname | gzip > $backupFile");


include 'closedb.php';

?>

</body>
</html>
everything i jus as u said....but in vain...no db was dumped...i ran the code in netbeans....is der anythin else to be done other than the code n simply runnin it...

Edited by saiprem: n/a

0

im creating a database replication gui,

replication code works perfectly through command line....
command line code for replication is shown below...nw i need to create a gui for replication...so im using php through netbeans... but im facing problem in some commands while executing with php..

mysql> create database dbname; // works well using php
mysql>create table tbname( id int(20) not null, name varchar(20) not null);// creation is fyn with php

mysql> create user 'user'@'%. ip' identified by 'passwd'; // hw to implement dis using php

mysql> grant replication slave on *.* to 'user'@'%. ip'; // hw to implement dis using php

mysql>flush tables with read lock; // works with php

mysql>show master status ; //works with php

mysqldump -u root -p dbname > /home/laks/Desktop/foldername/backup5.sql // hav asked u abt dis before

scp /home/laks/Desktop/foldername/backup5.sql user@ip:/path/ // want to know the php code

mysql -u root -p hanuman < /home/neethu/Desktop/time/backup5.sql // how to implement did in php

change master to master_host='ip', master_user='user', master_password='pass', master_log_file='mysql-bin.000026', master_log_pos=106; // php code for change master to.... master_log_file and master_log_pos are obtained from show master status

mysql -u root -p dbname < /home/laks/Desktop/foldername/backup5.sql // php code to implement dis

start slave;
show slave status

pls help me if possible...awaiting ur response

0

hey thanx a lot...it woked finally...i could dump db...thnx a lot .... apache root didnt have write permission dat was the problem...

0

how to implement the commands using php....


mysql> create user 'user'@'%. ip' identified by 'passwd'; // hw to implement dis using php

mysql> grant replication slave on *.* to 'user'@'%. ip'; // hw to implement dis using php
scp /home/laks/Desktop/foldername/backup5.sql user@ip:/path/ // want to know the php code

mysql -u root -p hanuman < /home/neethu/Desktop/time/backup5.sql // how to implement did in php

change master to master_host='ip', master_user='user', master_password='pass', master_log_file='mysql-bin.000026', master_log_pos=106; // php code for change master to.... master_log_file and master_log_pos are obtained from show master status

mysql -u root -p dbname < /home/laks/Desktop/foldername/backup5.sql // php code to implement dis

awaiting ur response...

0

All mysql queries can be written in mysql_query function(PHP predefined function)

All shell commands can be executed using anyone of these functions
system, shell_exec, exec and passthru functions(PHP predefined functions)

how to implement the commands using php....


mysql> create user 'user'@'%. ip' identified by 'passwd'; // hw to implement dis using php

mysql> grant replication slave on *.* to 'user'@'%. ip'; // hw to implement dis using php
scp /home/laks/Desktop/foldername/backup5.sql user@ip:/path/ // want to know the php code

mysql -u root -p hanuman < /home/neethu/Desktop/time/backup5.sql // how to implement did in php

change master to master_host='ip', master_user='user', master_password='pass', master_log_file='mysql-bin.000026', master_log_pos=106; // php code for change master to.... master_log_file and master_log_pos are obtained from show master status

mysql -u root -p dbname < /home/laks/Desktop/foldername/backup5.sql // php code to implement dis

awaiting ur response...

0

hey i tried doing ssh to another pc through wired connection...but i cant access the documents in dat pc....on the other hand , my documents can be accessed while trying to ssh from dat pc...v created a wired connection, put static ip to our systems n tries to ssh.... till a week ago i could ssh successfully but nw der is a problem...dis is very uncertain...

dis is the error i get wen i ssh:
cannot display location "sftp://aloka@192.168.0.8/"
connection refused by server


i tried the following on my terminal:

lakshmi@lachu-laptop:~$ ssh 192.168.0.5
ssh: connect to host 192.168.0.5 port 22: Connection refused
lakshmi@lachu-laptop:~$ ssh 192.168.0.5 "aloka -a"ssh: connect to host 192.168.0.5 port 22: Connection refused
lakshmi@lachu-laptop:~$ sudo tcpdump -vvvXX
[sudo] password for lakshmi:
tcpdump: listening on virbr0, link-type EN10MB (Ethernet), capture size 96 bytes
^Z
[1]+ Stopped sudo tcpdump -vvvXX
lakshmi@lachu-laptop:~$ netstat -l
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 *:8775 *:* LISTEN
tcp 0 0 localhost:mysql *:* LISTEN
tcp 0 0 *:www *:* LISTEN
tcp 0 0 lachu-laptop.loc:domain *:* LISTEN
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 localhost:ipp *:* LISTEN
^Z
[2]+ Stopped netstat -l
lakshmi@lachu-laptop:~$ pgrep sshd
1124
5175
5243
20040
20105
lakshmi@lachu-laptop:~$ ssh -p 22 aloka@192.168.0.5
ssh: connect to host 192.168.0.5 port 22: Connection refused
lakshmi@lachu-laptop:~$ ssh -l aloka 192.168.0.5
ssh: connect to host 192.168.0.5 port 22: Connection refused
lakshmi@lachu-laptop:~$ ssh 192.168.0.6@localhost
192.168.0.6@localhost's password:
Permission denied, please try again.
192.168.0.6@localhost's password:
Permission denied, please try again.
192.168.0.6@localhost's password:

pls help me...waiting 4 ur response...

0

There will be a service called sftpd, check it in the etc directory, might it has stopped, restart that service.

0

hi....i coudnt find sftpd...i could find sftpd in /usr/share/doc/libssh2-1-dev/examples/simple/sftpdir.c.gz....it has socket programming n i dont know how to restart the service of sftp as u said...i could ssh to another pc successfully... prob is with dis particular pc but dis pc can ssh into mine...very uncertain...pls get me out of dis...

0

So there is no sftp service in your linux system, try installing it and try doing sftp transfers

0

sftp service comes along with ssh rit???...i hav ssh n others can ssh into mine...even i can ssh into few.... but in few this server refused error occurs....

0

most of Linux distributions come along with SFTP installed, If it is not found in your linux distribution then you need to install it in your Linux OS.

0

i can do scp manually n it works all well....but wen i run this code i get these errors...

Warning: ssh2_scp_send(/home/lakshmi/Desktop/new/Cap09a.ppt ) [function.ssh2-scp-send]: failed to open stream: No such file or directory in /home/lakshmi/Desktop/lachu/PhpProject3/my project.php on line 118

Warning: ssh2_scp_send() [function.ssh2-scp-send]: Unable to read source file in /home/lakshmi/Desktop/lachu/PhpProject3/my project.php on line 118

this is da code that i tried implementing....
$conn1 = ssh2_connect('192.168.0.3', 22); //remote ip
ssh2_auth_password($conn1, 'remote username', 'remote password');
ssh2_scp_send($conn1, '/home/lakshmi/Desktop/new/Cap09a.ppt ', '/home/neethu/Desktop/Newtrials/', 0644);

0

May be because of the permissions problem to file,
check your file "/home/lakshmi/Desktop/new/Cap09a.ppt" is having proper read permissions, after changing the permissions
Just copy the code below and try

$conn1 = ssh2_connect('192.168.0.3', 22); //remote ip
ssh2_auth_password($conn1, 'remote username', 'remote password'); 
ssh2_scp_send($conn1, '/home/lakshmi/Desktop/new/Cap09a.ppt', '/home/neethu/Desktop/Newtrials/Cap09a.ppt', 0644);

I hope it will works for you, because there is a white space added after your local filename

i can do scp manually n it works all well....but wen i run this code i get these errors...

Warning: ssh2_scp_send(/home/lakshmi/Desktop/new/Cap09a.ppt ) [function.ssh2-scp-send]: failed to open stream: No such file or directory in /home/lakshmi/Desktop/lachu/PhpProject3/my project.php on line 118

Warning: ssh2_scp_send() [function.ssh2-scp-send]: Unable to read source file in /home/lakshmi/Desktop/lachu/PhpProject3/my project.php on line 118

this is da code that i tried implementing....
$conn1 = ssh2_connect('192.168.0.3', 22); //remote ip
ssh2_auth_password($conn1, 'remote username', 'remote password');
ssh2_scp_send($conn1, '/home/lakshmi/Desktop/new/Cap09a.ppt ', '/home/neethu/Desktop/Newtrials/', 0644);

Edited by saiprem: n/a

0

hey prob regardin ssh2_scp_send was solved....it was due to lack of permission...after assignin correct permission i copied ur code... nw it works perfectly...n ssh prob is also solved i restarted ssh of the pc which i couldnt access...hey tanx a lot!!! u guys r doin a gr8 job!!!

0

this is wht i want to implement....
mysql -u root -p db_name < /home/lakshmi/Desktop/path/backup5.sql

in php
$File= '/home/lakshmi/Desktop/new/backup5.sql';
system("mysql -u $dbuser -p $dbpass --quick $dbname < $File");

above php code worked perfectly but after restarting my pc it stopped workin n da output i get is....

mysql Ver 14.14 Distrib 5.1.37, for debian-linux-gnu (i486) using EditLine wrapper Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL license Usage: mysql [OPTIONS] [database] -?, --help Display this help and exit. -I, --help Synonym for -? --auto-rehash Enable automatic rehashing. One doesn't need to use 'rehash' to get table and field completion, but startup and reconnecting may take a longer time. Disable with --disable-auto-rehash. -A, --no-auto-rehash No automatic rehashing. One has to use 'rehash' to get table and field completion. This gives a quicker start of mysql and disables rehashing on reconnect. WARNING: options deprecated; use --disable-auto-rehash instead. -B, --batch Don't use history file. Disable interactive behavior. (Enables --silent) --character-sets-dir=name Directory where character sets are. --column-type-info Display column type information. -c, --comments Preserve comments. Send comments to the server. The default is --skip-comments (discard comments), enable with --comments -C, --compress Use compression in server/client protocol. -#, --debug[=#] This is a non-debug version. Catch this and exit --debug-check Check memory and open file usage at exit. -T, --debug-info Print some debug info at exit. -D, --database=name Database to use. --default-character-set=name Set the default character set. --delimiter=name Delimiter to be used. -e, --execute=name Execute command and quit. (Disables --force and history file) -E, --vertical Print the output of a query (rows) vertically. -f, --force Continue even if we get an sql error. -G, --named-commands Enable named commands. Named commands mean this program's internal commands; see mysql> help . When enabled, the named commands can be used from any line of the query, otherwise only from the first line, before an enter. Disable with --disable-named-commands. This option is disabled by default. -g, --no-named-commands Named commands are disabled. Use \* form only, or use named commands only in the beginning of a line ending with a semicolon (;) Since version 10.9 the client now starts with this option ENABLED by default! Disable with '-G'. Long format commands still work from the first line. WARNING: option deprecated; use --disable-named-commands instead. -i, --ignore-spaces Ignore space after function names. --local-infile Enable/disable LOAD DATA LOCAL INFILE. -b, --no-beep Turn off beep on error. -h, --host=name Connect to host. -H, --html Produce HTML output. -X, --xml Produce XML output --line-numbers Write line numbers for errors. -L, --skip-line-numbers Don't write line number for errors. WARNING: -L is deprecated, use long version of this option instead. -n, --unbuffered Flush buffer after each query. --column-names Write column names in results. -N, --skip-column-names Don't write column names in results. WARNING: -N is deprecated, use long version of this options instead. -O, --set-variable=name Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value. --sigint-ignore Ignore SIGINT (CTRL-C) -o, --one-database Only update the default database. This is useful for skipping updates to other database in the update log. --pager[=name] Pager to use to display results. If you don't supply an option the default pager is taken from your ENV variable PAGER. Valid pagers are less, more, cat [> filename], etc. See interactive help (\h) also. This option does not work in batch mode. Disable with --disable-pager. This option is disabled by default. --no-pager Disable pager and print to stdout. See interactive help (\h) also. WARNING: option deprecated; use --disable-pager instead. -p, --password[=name] Password to use when connecting to server. If password is not given it's asked from the tty. -P, --port=# Port number to use for connection or 0 for default to, in order of preference, my.cnf, $MYSQL_TCP_PORT, /etc/services, built-in default (3306). --prompt=name Set the mysql prompt to this value. --protocol=name The protocol of connection (tcp,socket,pipe,memory). -q, --quick Don't cache result, print it row by row. This may slow down the server if the output is suspended. Doesn't use history file. -r, --raw Write fields without conversion. Used with --batch. --reconnect Reconnect if the connection is lost. Disable with --disable-reconnect. This option is enabled by default. -s, --silent Be more silent. Print results with a tab as separator, each row on new line. -S, --socket=name Socket file to use for connection. --ssl Enable SSL for connection (automatically enabled with other flags). Disable with --skip-ssl. --ssl-ca=name CA file in PEM format (check OpenSSL docs, implies --ssl). --ssl-capath=name CA directory (check OpenSSL docs, implies --ssl). --ssl-cert=name X509 cert in PEM format (implies --ssl). --ssl-cipher=name SSL cipher to use (implies --ssl). --ssl-key=name X509 key in PEM format (implies --ssl). --ssl-verify-server-cert Verify server's "Common Name" in its cert against hostname used when connecting. This option is disabled by default. -t, --table Output in table format. --tee=name Append everything into outfile. See interactive help (\h) also. Does not work in batch mode. Disable with --disable-tee. This option is disabled by default. --no-tee Disable outfile. See interactive help (\h) also. WARNING: option deprecated; use --disable-tee instead -u, --user=name User for login if not current user. -U, --safe-updates Only allow UPDATE and DELETE that uses keys. -U, --i-am-a-dummy Synonym for option --safe-updates, -U. -v, --verbose Write more. (-v -v -v gives the table output format). -V, --version Output version information and exit. -w, --wait Wait and retry if connection is down. --connect_timeout=# Number of seconds before connection timeout. --max_allowed_packet=# Max packet length to send to, or receive from server --net_buffer_length=# Buffer for TCP/IP and socket communication --select_limit=# Automatic limit for SELECT when using --safe-updates --max_join_size=# Automatic limit for rows in a join when using --safe-updates --secure-auth Refuse client connecting to server if it uses old (pre-4.1.1) protocol --server-arg=name Send embedded server this as a parameter. --show-warnings Show warnings after every statement. Default options are read from the following files in the given order: /etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf The following groups are read: mysql client The following options may be given as the first argument: --print-defaults Print the program argument list and exit --no-defaults Don't read default options from any options file --defaults-file=# Only read default options from the given file # --defaults-extra-file=# Read this file after the global files are read Variables (--variable-name=value) and boolean options {FALSE|TRUE} Value (after reading options) --------------------------------- ----------------------------- auto-rehash TRUE character-sets-dir (No default value) column-type-info FALSE comments FALSE compress FALSE debug-check FALSE debug-info FALSE database (No default value) default-character-set latin1 delimiter ; vertical FALSE force FALSE named-commands FALSE ignore-spaces FALSE local-infile FALSE no-beep FALSE host (No default value) html FALSE xml FALSE line-numbers TRUE unbuffered FALSE column-names TRUE sigint-ignore FALSE port 3306 prompt mysql> quick FALSE raw FALSE reconnect FALSE socket /var/run/mysqld/mysqld.sock ssl FALSE ssl-ca (No default value) ssl-capath (No default value) ssl-cert (No default value) ssl-cipher (No default value) ssl-key (No default value) ssl-verify-server-cert FALSE table FALSE user root safe-updates FALSE i-am-a-dummy FALSE connect_timeout 0 max_allowed_packet 16777216 net_buffer_length 16384 select_limit 1000 max_join_size 1000000 secure-auth FALSE show-warnings FALSE There are 0 rows

0

Never put space after -p in your syntax, i really wonder how it has worked for you.

use like this
system("mysql -u $dbuser -p$dbpass --quick $dbname < $File");

and change the settings in my.ini or my.cnf which ever you have

max_allowed_packet
connection_time

this is wht i want to implement....
mysql -u root -p db_name < /home/lakshmi/Desktop/path/backup5.sql

in php
$File= '/home/lakshmi/Desktop/new/backup5.sql';
system("mysql -u $dbuser -p $dbpass --quick $dbname < $File");

above php code worked perfectly but after restarting my pc it stopped workin n da output i get is....

mysql Ver 14.14 Distrib 5.1.37, for debian-linux-gnu (i486) using EditLine wrapper Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL license Usage: mysql [OPTIONS] [database] -?, --help Display this help and exit. -I, --help Synonym for -? --auto-rehash Enable automatic rehashing. One doesn't need to use 'rehash' to get table and field completion, but startup and reconnecting may take a longer time. Disable with --disable-auto-rehash. -A, --no-auto-rehash No automatic rehashing. One has to use 'rehash' to get table and field completion. This gives a quicker start of mysql and disables rehashing on reconnect. WARNING: options deprecated; use --disable-auto-rehash instead. -B, --batch Don't use history file. Disable interactive behavior. (Enables --silent) --character-sets-dir=name Directory where character sets are. --column-type-info Display column type information. -c, --comments Preserve comments. Send comments to the server. The default is --skip-comments (discard comments), enable with --comments -C, --compress Use compression in server/client protocol. -#, --debug[=#] This is a non-debug version. Catch this and exit --debug-check Check memory and open file usage at exit. -T, --debug-info Print some debug info at exit. -D, --database=name Database to use. --default-character-set=name Set the default character set. --delimiter=name Delimiter to be used. -e, --execute=name Execute command and quit. (Disables --force and history file) -E, --vertical Print the output of a query (rows) vertically. -f, --force Continue even if we get an sql error. -G, --named-commands Enable named commands. Named commands mean this program's internal commands; see mysql> help . When enabled, the named commands can be used from any line of the query, otherwise only from the first line, before an enter. Disable with --disable-named-commands. This option is disabled by default. -g, --no-named-commands Named commands are disabled. Use \* form only, or use named commands only in the beginning of a line ending with a semicolon (;) Since version 10.9 the client now starts with this option ENABLED by default! Disable with '-G'. Long format commands still work from the first line. WARNING: option deprecated; use --disable-named-commands instead. -i, --ignore-spaces Ignore space after function names. --local-infile Enable/disable LOAD DATA LOCAL INFILE. -b, --no-beep Turn off beep on error. -h, --host=name Connect to host. -H, --html Produce HTML output. -X, --xml Produce XML output --line-numbers Write line numbers for errors. -L, --skip-line-numbers Don't write line number for errors. WARNING: -L is deprecated, use long version of this option instead. -n, --unbuffered Flush buffer after each query. --column-names Write column names in results. -N, --skip-column-names Don't write column names in results. WARNING: -N is deprecated, use long version of this options instead. -O, --set-variable=name Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value. --sigint-ignore Ignore SIGINT (CTRL-C) -o, --one-database Only update the default database. This is useful for skipping updates to other database in the update log. --pager[=name] Pager to use to display results. If you don't supply an option the default pager is taken from your ENV variable PAGER. Valid pagers are less, more, cat [> filename], etc. See interactive help (\h) also. This option does not work in batch mode. Disable with --disable-pager. This option is disabled by default. --no-pager Disable pager and print to stdout. See interactive help (\h) also. WARNING: option deprecated; use --disable-pager instead. -p, --password[=name] Password to use when connecting to server. If password is not given it's asked from the tty. -P, --port=# Port number to use for connection or 0 for default to, in order of preference, my.cnf, $MYSQL_TCP_PORT, /etc/services, built-in default (3306). --prompt=name Set the mysql prompt to this value. --protocol=name The protocol of connection (tcp,socket,pipe,memory). -q, --quick Don't cache result, print it row by row. This may slow down the server if the output is suspended. Doesn't use history file. -r, --raw Write fields without conversion. Used with --batch. --reconnect Reconnect if the connection is lost. Disable with --disable-reconnect. This option is enabled by default. -s, --silent Be more silent. Print results with a tab as separator, each row on new line. -S, --socket=name Socket file to use for connection. --ssl Enable SSL for connection (automatically enabled with other flags). Disable with --skip-ssl. --ssl-ca=name CA file in PEM format (check OpenSSL docs, implies --ssl). --ssl-capath=name CA directory (check OpenSSL docs, implies --ssl). --ssl-cert=name X509 cert in PEM format (implies --ssl). --ssl-cipher=name SSL cipher to use (implies --ssl). --ssl-key=name X509 key in PEM format (implies --ssl). --ssl-verify-server-cert Verify server's "Common Name" in its cert against hostname used when connecting. This option is disabled by default. -t, --table Output in table format. --tee=name Append everything into outfile. See interactive help (\h) also. Does not work in batch mode. Disable with --disable-tee. This option is disabled by default. --no-tee Disable outfile. See interactive help (\h) also. WARNING: option deprecated; use --disable-tee instead -u, --user=name User for login if not current user. -U, --safe-updates Only allow UPDATE and DELETE that uses keys. -U, --i-am-a-dummy Synonym for option --safe-updates, -U. -v, --verbose Write more. (-v -v -v gives the table output format). -V, --version Output version information and exit. -w, --wait Wait and retry if connection is down. --connect_timeout=# Number of seconds before connection timeout. --max_allowed_packet=# Max packet length to send to, or receive from server --net_buffer_length=# Buffer for TCP/IP and socket communication --select_limit=# Automatic limit for SELECT when using --safe-updates --max_join_size=# Automatic limit for rows in a join when using --safe-updates --secure-auth Refuse client connecting to server if it uses old (pre-4.1.1) protocol --server-arg=name Send embedded server this as a parameter. --show-warnings Show warnings after every statement. Default options are read from the following files in the given order: /etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf The following groups are read: mysql client The following options may be given as the first argument: --print-defaults Print the program argument list and exit --no-defaults Don't read default options from any options file --defaults-file=# Only read default options from the given file # --defaults-extra-file=# Read this file after the global files are read Variables (--variable-name=value) and boolean options {FALSE|TRUE} Value (after reading options) --------------------------------- ----------------------------- auto-rehash TRUE character-sets-dir (No default value) column-type-info FALSE comments FALSE compress FALSE debug-check FALSE debug-info FALSE database (No default value) default-character-set latin1 delimiter ; vertical FALSE force FALSE named-commands FALSE ignore-spaces FALSE local-infile FALSE no-beep FALSE host (No default value) html FALSE xml FALSE line-numbers TRUE unbuffered FALSE column-names TRUE sigint-ignore FALSE port 3306 prompt mysql> quick FALSE raw FALSE reconnect FALSE socket /var/run/mysqld/mysqld.sock ssl FALSE ssl-ca (No default value) ssl-capath (No default value) ssl-cert (No default value) ssl-cipher (No default value) ssl-key (No default value) ssl-verify-server-cert FALSE table FALSE user root safe-updates FALSE i-am-a-dummy FALSE connect_timeout 0 max_allowed_packet 16777216 net_buffer_length 16384 select_limit 1000 max_join_size 1000000 secure-auth FALSE show-warnings FALSE There are 0 rows

Edited by saiprem: n/a

0

hey tanx a lot for da previous reply....

we r setting up a cloud using ubuntu 9.10...
we hav to create an image , upload and register it....image creation is complete but while uploading i get error : no route to host error....

this is the code in command prompt:
lakshmi@lachu-laptop:~$ euca-upload-bundle -b ubuntu -m /tmp/root.img.manifest.xml
Checking bucket: ubuntu
Traceback (most recent call last):
File "/usr/bin/euca-upload-bundle", line 226, in <module>
main()
File "/usr/bin/euca-upload-bundle", line 209, in main
bucket_instance = ensure_bucket(conn, bucket, canned_acl)
File "/usr/bin/euca-upload-bundle", line 87, in ensure_bucket
bucket_instance = connection.get_bucket(bucket)
File "/usr/lib/pymodules/python2.6/boto/s3/connection.py", line 238, in get_bucket
rs = bucket.get_all_keys(None, maxkeys=0)
File "/usr/lib/pymodules/python2.6/boto/s3/bucket.py", line 204, in get_all_keys
headers=headers, query_args=s)
File "/usr/lib/pymodules/python2.6/boto/s3/connection.py", line 305, in make_request
data, host, auth_path, sender)
File "/usr/lib/pymodules/python2.6/boto/connection.py", line 419, in make_request
return self._mexe(method, path, data, headers, host, sender)
File "/usr/lib/pymodules/python2.6/boto/connection.py", line 398, in _mexe
raise e
socket.error: [Errno 113] No route to host

waitin for ur reply asap....

0

Hi Lakshmi, I am really sorry :S I don't know python, the script in your post seems that python script.

hey tanx a lot for da previous reply....

we r setting up a cloud using ubuntu 9.10...
we hav to create an image , upload and register it....image creation is complete but while uploading i get error : no route to host error....

this is the code in command prompt:
lakshmi@lachu-laptop:~$ euca-upload-bundle -b ubuntu -m /tmp/root.img.manifest.xml
Checking bucket: ubuntu
Traceback (most recent call last):
File "/usr/bin/euca-upload-bundle", line 226, in <module>
main()
File "/usr/bin/euca-upload-bundle", line 209, in main
bucket_instance = ensure_bucket(conn, bucket, canned_acl)
File "/usr/bin/euca-upload-bundle", line 87, in ensure_bucket
bucket_instance = connection.get_bucket(bucket)
File "/usr/lib/pymodules/python2.6/boto/s3/connection.py", line 238, in get_bucket
rs = bucket.get_all_keys(None, maxkeys=0)
File "/usr/lib/pymodules/python2.6/boto/s3/bucket.py", line 204, in get_all_keys
headers=headers, query_args=s)
File "/usr/lib/pymodules/python2.6/boto/s3/connection.py", line 305, in make_request
data, host, auth_path, sender)
File "/usr/lib/pymodules/python2.6/boto/connection.py", line 419, in make_request
return self._mexe(method, path, data, headers, host, sender)
File "/usr/lib/pymodules/python2.6/boto/connection.py", line 398, in _mexe
raise e
socket.error: [Errno 113] No route to host

waitin for ur reply asap....

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.