2

Notes: I tried all questions & answers related this topic. Additionally and I tried related questions and try to solve it but not success. So please read my question thoroughly.

Relative answer search

1. Getting 0KB of size file while backup mysql database using mysql dump

2. Using PHP script: why mysqldump does not dump sql file?

3. Mysql PHP backup database using mysqldump

I want to Full database mysql (store procedure + table + trigger ) i try to code then not get any error but 0 kb database Download

I connect Mysql CMD Got Error like this

MYSqldump:Got error:2003 : can't connect to Mysql Server '172.30.70.54' <10060> when trying to connect

Cmd Code Execute

mysqldump  --user=root --password= --host=172.30.70.54 dv-admin > db_backup5.sql 

enter image description here

Php Script

<?php
    $dbhost = '172.30.70.54';
    $dbuser = 'root';
    $dbpass = 'mypass';
    $dbname='mydb';
    $toDay = date('d-m-Y');
    shell_exec("mysqldump --opt --routines -h$dbhost -u$dbuser -p$dbpass --single-transaction $dbname  > db_backup.sql");
    system("mysqldump -opt -routines -h$dbhost -u$dbuser -p$dbpass -single-transaction $dbname  > db_backup2.sql");
    ?>
Community
  • 1
  • 1
Sumit patel
  • 3,807
  • 9
  • 34
  • 61
  • and what's the error ? what's the real issue? – hassan Apr 03 '17 at 11:12
  • Try to run this dump command from cmd or cli first & check the file size – Dipanwita Kundu Apr 03 '17 at 11:14
  • i try to code then not get any error but 0 kb database Download – Sumit patel Apr 03 '17 at 11:14
  • If you dump from a remote server read here more : http://stackoverflow.com/questions/2989724/how-to-mysqldump-remote-db-from-local-machine – JustOnUnderMillions Apr 03 '17 at 11:16
  • 2
    I think you should give space between -h $dbhost ...... – krishn Patel Apr 03 '17 at 11:18
  • i also try `-h $dbhost` .. but not succes – Sumit patel Apr 03 '17 at 11:18
  • Perhaps you should put the arguments **between single quotes**, like `system("mysqldump -opt -routines -h$dbhost -u$dbuser -p$dbp...` to `system("mysqldump '-opt' '-routines' '-h$dbhost' '-u$dbuser' '-p$dbp'...`. If your username/password contains a space, then it is seen by the shell as two arguments. – Willem Van Onsem Apr 03 '17 at 11:20
  • i try your code @WillemVanOnsem but again `0 KB` Download – Sumit patel Apr 03 '17 at 11:24
  • 1
    Have you tried running `mysqldump` from terminal before creating this script? What's the use of this script anyway? Why not `.sh` from scratch? If you're trying to back MySQL up via browser, I'll just wish you good luck, it's an extremely bad idea. – Mjh Apr 03 '17 at 12:13
  • `Can't connect` = you don't have access to connect to it remotely(either firewall is blocking you, or you need to add the settings to allow your IP), assuming your credentials are right. If your site is on cPanel, go to it and grant access to your IP. – Prix Apr 04 '17 at 06:11
  • i already set all grant access in database . my database store to cloud 1 &1 server – Sumit patel Apr 04 '17 at 06:13
  • its not about granting all accesses, its about having an user that is allowed to your IP for example: `GRANT ALL PRIVILEGES ON db.* to 'user'@'yourip' IDENTIFIED BY 'yourpassword'; FLUSH PRIVILEGES;` note the `to 'user'@'yourip'` in the command, **and for this to work your IP also needs to be allowed thru the server firewall** – Prix Apr 04 '17 at 06:14
  • i try @Prix code .but get other error like `grant' is not recognized as an internal or external command operable program or batch file` – Sumit patel Apr 04 '17 at 06:39
  • that is not a console command, its a mysql command, I suggest you either hire some one that understand what needs to be done or read more on how mysql, mysqldump, and mysqladmin CLI's work – Prix Apr 04 '17 at 06:56

0 Answers0