Re: [PHP] mysqldump
2010/8/18 Daniel P. Brown daniel.br...@parasane.net: On Tue, Aug 17, 2010 at 15:19, tedd t...@sperling.com wrote: Bingo -- that worked. It's interesting that a space is optional between -u and user, but required to be absent between -p and password. Seems not symmetrical to me. The command I sent was because - as I said in the original thread - passing any password directly to the command line is Very Bad[tm]. If you're passing it via exec(), though, and don't want to use an 'expect' shell, passing it directly to -p is at least a bit less dangerous. Plus, doing so will not leave anything in your ~/.bash_history on the server. That said, sorry for appearing inattentive, despite this being directed right at me. I have been out of the office more than in for the last couple of weeks, while working on a ton of new stuff. Eventually it will go back to normal. -- /Daniel P. Brown UNADVERTISED DEDICATED SERVER SPECIALS SAME-DAY SETUP Just ask me what we're offering today! daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I recommend gzipping it on the fly and if you're using own MYSQL functions and /or stored procedures, then I'd add --routines as parameter to include these in your sum. Here's my command line: $ mysqldump -u USERNAME -p --opt --single-transaction --routines DATABASENAME | gzip sqldump.sql.gz Note that you must only replace Databasename and Username in the example.. mysqldump will ask for the passwort. If you specify your password in the command line, then you end up haviung it in your shell history which can make it easy for crackers. --opt means the same as: --add-drop-table, --add-locks, --create-options, --quick, --extended-insert, --lock-tables, --set-charset, and --disable-keys. and is enabled by default. Regards -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysqldump
On Tue, Aug 17, 2010 at 15:19, tedd t...@sperling.com wrote: Bingo -- that worked. It's interesting that a space is optional between -u and user, but required to be absent between -p and password. Seems not symmetrical to me. The command I sent was because - as I said in the original thread - passing any password directly to the command line is Very Bad[tm]. If you're passing it via exec(), though, and don't want to use an 'expect' shell, passing it directly to -p is at least a bit less dangerous. Plus, doing so will not leave anything in your ~/.bash_history on the server. That said, sorry for appearing inattentive, despite this being directed right at me. I have been out of the office more than in for the last couple of weeks, while working on a ton of new stuff. Eventually it will go back to normal. -- /Daniel P. Brown UNADVERTISED DEDICATED SERVER SPECIALS SAME-DAY SETUP Just ask me what we're offering today! daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysqldump
Hi gang: At 6:11 PM -0400 8/13/10, Daniel P. Brown wrote: Easiest method, from the command line on the server from which you want to dump the database: mysqldump -u user -p database_name outfile.sql That might be the easiest, but all I get is an empty file. I've tried many different variations of the syntax using exec(), but nothing produces any subsistent output. What am I doing wrong? As for accessing a command line, I am still in the dark as to how to do that. Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysqldump
On 10-08-17 02:08 PM, tedd wrote: Hi gang: At 6:11 PM -0400 8/13/10, Daniel P. Brown wrote: Easiest method, from the command line on the server from which you want to dump the database: mysqldump -u user -p database_name outfile.sql Command is wrong... should be: mysqldump -u user -p password database_name outfile.sql That might be the easiest, but all I get is an empty file. I've tried many different variations of the syntax using exec(), but nothing produces any subsistent output. What am I doing wrong? Have you checked the return code of running exec? It may be the mysqldump program isn't in your path. As for accessing a command line, I am still in the dark as to how to do that. In windows you can do Start - Run - cmd.exe to load the command prompt terminal. You could probably put the above mysqldump command directly into the run prompt, but I don't know what it's default path is... but a small tweak might be: C:\PATH\TO\mysqlump -u user -p password database_name C:\outfile.sql Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysqldump
At 2:17 PM -0400 8/17/10, Robert Cummings wrote: On 10-08-17 02:08 PM, tedd wrote: Hi gang: At 6:11 PM -0400 8/13/10, Daniel P. Brown wrote: Easiest method, from the command line on the server from which you want to dump the database: mysqldump -u user -p database_name outfile.sql Command is wrong... should be: mysqldump -u user -p password database_name outfile.sql I did catch that, but did not correct it in my post (considering it was a direct quote). --- That might be the easiest, but all I get is an empty file. I've tried many different variations of the syntax using exec(), but nothing produces any subsistent output. What am I doing wrong? Have you checked the return code of running exec? It may be the mysqldump program isn't in your path. No, I didn't -- however, I just did this (using the correct user, password, and database name): exec('mysqldump -u user -p password databaseName outfile.txt',$a,$b); And received back an empty array for $a and '2' for $b. I don't know what that means. --- As for accessing a command line, I am still in the dark as to how to do that. In windows you can do Start - Run - cmd.exe to load the command prompt terminal. You could probably put the above mysqldump command directly into the run prompt, but I don't know what it's default path is... but a small tweak might be: C:\PATH\TO\mysqlump -u user -p password database_name C:\outfile.sql I'm neither on Windozes nor the host. I am on a hosted account and that may be the problem. However, I've been told that I *can* access the command line, I am just clueless as to how to do it. In the past I have been reluctant to try because I don't want to screw things up. You see, it's Okay if I screw up my own system, but someone else's, I would rather not. However, I would like to know how to do it safely. Thanks for your time. Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysqldump
On Aug 17, 2010, at 11:40 AM, tedd wrote: At 2:17 PM -0400 8/17/10, Robert Cummings wrote: On 10-08-17 02:08 PM, tedd wrote: Hi gang: At 6:11 PM -0400 8/13/10, Daniel P. Brown wrote: Easiest method, from the command line on the server from which you want to dump the database: mysqldump -u user -p database_name outfile.sql Command is wrong... should be: mysqldump -u user -p password database_name outfile.sql I did catch that, but did not correct it in my post (considering it was a direct quote). --- Actually, mysqldump -u user -p password database_name outfile.sql is also the incorrect command. When providing the password in the command, there should not be a space between the -p and the actual password. Try mysqldump -u user -ppassword database_name outfile.sql and see if that gets you anywhere. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysqldump
On 10-08-17 02:45 PM, Mari Masuda wrote: On Aug 17, 2010, at 11:40 AM, tedd wrote: At 2:17 PM -0400 8/17/10, Robert Cummings wrote: On 10-08-17 02:08 PM, tedd wrote: Hi gang: At 6:11 PM -0400 8/13/10, Daniel P. Brown wrote: Easiest method, from the command line on the server from which you want to dump the database: mysqldump -u user -p database_name outfile.sql Command is wrong... should be: mysqldump -u user -p password database_name outfile.sql I did catch that, but did not correct it in my post (considering it was a direct quote). --- Actually, mysqldump -u user -p password database_name outfile.sql is also the incorrect command. When providing the password in the command, there should not be a space between the -p and the actual password. Try mysqldump -u user -ppassword database_name outfile.sql and see if that gets you anywhere. That's actually funny... I never put spaces in for the user or password when using the short parameter method and had quickly tried with the space before posting... I had tried with the user though and it work so I had assumed it worked for password also. Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysqldump
On Tue, Aug 17, 2010 at 2:55 PM, Robert Cummings rob...@interjinn.com wrote: On 10-08-17 02:45 PM, Mari Masuda wrote: On Aug 17, 2010, at 11:40 AM, tedd wrote: At 2:17 PM -0400 8/17/10, Robert Cummings wrote: On 10-08-17 02:08 PM, tedd wrote: Hi gang: At 6:11 PM -0400 8/13/10, Daniel P. Brown wrote: Easiest method, from the command line on the server from which you want to dump the database: mysqldump -u user -p database_name outfile.sql Command is wrong... should be: mysqldump -u user -p password database_name outfile.sql I did catch that, but did not correct it in my post (considering it was a direct quote). --- Actually, mysqldump -u user -p password database_name outfile.sql is also the incorrect command. When providing the password in the command, there should not be a space between the -p and the actual password. Try mysqldump -u user -ppassword database_name outfile.sql and see if that gets you anywhere. That's actually funny... I never put spaces in for the user or password when using the short parameter method and had quickly tried with the space before posting 'Playful with passwords the hacker does not expect', says yoda ... I had tried with the user though and it work so I had assumed it worked for password also. Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysqldump
On Tue, Aug 17, 2010 at 3:00 PM, David Hutto smokefl...@gmail.com wrote: On Tue, Aug 17, 2010 at 2:55 PM, Robert Cummings rob...@interjinn.com wrote: On 10-08-17 02:45 PM, Mari Masuda wrote: On Aug 17, 2010, at 11:40 AM, tedd wrote: At 2:17 PM -0400 8/17/10, Robert Cummings wrote: On 10-08-17 02:08 PM, tedd wrote: Hi gang: At 6:11 PM -0400 8/13/10, Daniel P. Brown wrote: Easiest method, from the command line on the server from which you want to dump the database: mysqldump -u user -p database_name outfile.sql Command is wrong... should be: mysqldump -u user -p password database_name outfile.sql I did catch that, but did not correct it in my post (considering it was a direct quote). --- Actually, mysqldump -u user -p password database_name outfile.sql is also the incorrect command. When providing the password in the command, there should not be a space between the -p and the actual password. Try mysqldump -u user -ppassword database_name outfile.sql and see if that gets you anywhere. That's actually funny... I never put spaces in for the user or password when using the short parameter method and had quickly tried with the space before posting 'Playful with passwords the hacker does not expect', says yoda ... I had tried with the user though and it work so I had assumed it worked for password also. Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Or playfulness he expects, but privacy he reaps, said her celibate highness -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysqldump
On 10-08-17 03:00 PM, David Hutto wrote: On Tue, Aug 17, 2010 at 2:55 PM, Robert Cummingsrob...@interjinn.com wrote: On 10-08-17 02:45 PM, Mari Masuda wrote: On Aug 17, 2010, at 11:40 AM, tedd wrote: At 2:17 PM -0400 8/17/10, Robert Cummings wrote: On 10-08-17 02:08 PM, tedd wrote: Hi gang: At 6:11 PM -0400 8/13/10, Daniel P. Brown wrote: Easiest method, from the command line on the server from which you want to dump the database: mysqldump -u user -p database_name outfile.sql Command is wrong... should be: mysqldump -u user -p password database_nameoutfile.sql I did catch that, but did not correct it in my post (considering it was a direct quote). --- Actually, mysqldump -u user -p password database_nameoutfile.sql is also the incorrect command. When providing the password in the command, there should not be a space between the -p and the actual password. Try mysqldump -u user -ppassword database_nameoutfile.sql and see if that gets you anywhere. That's actually funny... I never put spaces in for the user or password when using the short parameter method and had quickly tried with the space before posting 'Playful with passwords the hacker does not expect', says yoda I can't wait for 2050 when they release the new Star Wars super duper master awesome director's milk-it edition with 3 seconds of Yoda smoking a cigarette! :) Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysqldump
On Tue, Aug 17, 2010 at 3:04 PM, Robert Cummings rob...@interjinn.com wrote: On 10-08-17 03:00 PM, David Hutto wrote: On Tue, Aug 17, 2010 at 2:55 PM, Robert Cummingsrob...@interjinn.com wrote: On 10-08-17 02:45 PM, Mari Masuda wrote: On Aug 17, 2010, at 11:40 AM, tedd wrote: At 2:17 PM -0400 8/17/10, Robert Cummings wrote: On 10-08-17 02:08 PM, tedd wrote: Hi gang: At 6:11 PM -0400 8/13/10, Daniel P. Brown wrote: Easiest method, from the command line on the server from which you want to dump the database: mysqldump -u user -p database_name outfile.sql Command is wrong... should be: mysqldump -u user -p password database_name outfile.sql I did catch that, but did not correct it in my post (considering it was a direct quote). --- Actually, mysqldump -u user -p password database_name outfile.sql is also the incorrect command. When providing the password in the command, there should not be a space between the -p and the actual password. Try mysqldump -u user -ppassword database_name outfile.sql and see if that gets you anywhere. That's actually funny... I never put spaces in for the user or password when using the short parameter method and had quickly tried with the space before posting 'Playful with passwords the hacker does not expect', says yoda I can't wait for 2050 when they release the new Star Wars super duper master awesome director's milk-it edition with 3 seconds of Yoda smoking a cigarette! But they'll put it in a pretty 'Happy meal', with lighter included. :) Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysqldump
At 11:45 AM -0700 8/17/10, Mari Masuda wrote: Actually, mysqldump -u user -p password database_name outfile.sql is also the incorrect command. When providing the password in the command, there should not be a space between the -p and the actual password. Try mysqldump -u user -ppassword database_name outfile.sql and see if that gets you anywhere. Bingo -- that worked. It's interesting that a space is optional between -u and user, but required to be absent between -p and password. Seems not symmetrical to me. Many thanks. Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysqldump
On Aug 17, 2010, at 3:19 PM, tedd t...@sperling.com wrote: At 11:45 AM -0700 8/17/10, Mari Masuda wrote: Actually, mysqldump -u user -p password database_name outfile.sql is also the incorrect command. When providing the password in the command, there should not be a space between the -p and the actual password. Try mysqldump -u user -ppassword database_name outfile.sql and see if that gets you anywhere. Bingo -- that worked. It's interesting that a space is optional between -u and user, but required to be absent between -p and password. Seems not symmetrical to me Tedd... Goad you got the answer you needed as far as safely attacking the command line if my memory serves me correctly you are on a Mac so What you are looking for is a program called terminal. It's in the utilities folder of your harddrive. Then what you would do is assuming your host supports ssh is simply type into the terminal application: ssh youruzern...@yourdomain Say yes when it asks if you want to store the encryption key (I think that's what it's called) and then enter your password. Once all of that is done then just type in the command that was given and it will create the file just as you requested. Now I typed all that for the archives since you found a way to do t with exec but I'm always happy to help the archives where I can :) Have a great night! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysqldump problem from PHP
# [EMAIL PROTECTED] / 2006-10-23 16:34:16 +0100: It appears that it could be because the user that runs the scripts is not allowed to. When I run them on the commandline, I run them as the root user. that's very simple to check (man su) yes I know of CRONtabs but wont this still leave us with the user permission of running mysqldump? because essentially it will still be a PHP file to run the shell command to create the dump file? Are you concerned about what user it runs as or what language it's written in? No, cron will typically run as root. You don't need to involve PHP. How are those two things connected at all in the first place? It looks to me as if you are trying to use web scripting (PHP) to do the sysadmin on your server, for which other methods are more suitable. Those would be? What makes PHP unsuitable for non-web programming? Don't write the SMTP server in C, that's only for text editors. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysqldump problem from PHP
Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2006-10-23 16:34:16 +0100: It appears that it could be because the user that runs the scripts is not allowed to. When I run them on the commandline, I run them as the root user. that's very simple to check (man su) yes I know of CRONtabs but wont this still leave us with the user permission of running mysqldump? because essentially it will still be a PHP file to run the shell command to create the dump file? Are you concerned about what user it runs as or what language it's written in? No, cron will typically run as root. You don't need to involve PHP. How are those two things connected at all in the first place? It looks to me as if you are trying to use web scripting (PHP) to do the sysadmin on your server, for which other methods are more suitable. Those would be? What makes PHP unsuitable for non-web programming? I think the point was php doesn't *need* to be used for everything - use the best tool for the job. mysqldump is provided on the system and doesn't need to be called through php - what's the point of doing it that way? I use php for non-web programming at times when I can't find something else to do what I want.. most of the time though there's a tool already out there somewhere that does exactly what I want already (for sys admin tasks). -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysqldump problem from PHP
# [EMAIL PROTECTED] / 2006-10-24 17:58:45 +1000: Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2006-10-23 16:34:16 +0100: It looks to me as if you are trying to use web scripting (PHP) to do the sysadmin on your server, for which other methods are more suitable. Those would be? What makes PHP unsuitable for non-web programming? I think the point was php doesn't *need* to be used for everything - use the best tool for the job. IMO the post I argued was equating PHP with web scripting which is something else from what you're saying. Besides that you're right of course. It's just that I can see how PHP could be the best tool for this job: if your only tool is a hammer... mysqldump is provided on the system and doesn't need to be called through php - what's the point of doing it that way? You might want to have some logic around the mysqldump. I would write such things in a combination of POSIX sh and make, but that's just my taste. I use php for non-web programming at times when I can't find something else to do what I want.. most of the time though there's a tool already out there somewhere that does exactly what I want already (for sys admin tasks). Lucky! ;) -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysqldump problem from PHP
hi all, Im doing the following dump through PHP: $output = shell_exec('mysqldump '. $db_database .' '. $backup_path.$filename); It doesnt seem to work but when I run the exact same command (with appropriate values) in the command line it creates the dump file. What could be the reason for this? Thanks in advance. regards Angelo Zanetti Systems developer *Telephone:* +27 (021) 469 1052 *Mobile:* +27 (0) 72 441 3355 *Fax:*+27 (0) 86 681 5885 * Web:* http://www.zlogic.co.za *E-Mail:* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysqldump problem from PHP
write rights for apache/php user to the $backup_path? also is apache/php user allowed to run mysqldump? hi all, Im doing the following dump through PHP: $output = shell_exec('mysqldump '. $db_database .' '. $backup_path.$filename); It doesnt seem to work but when I run the exact same command (with appropriate values) in the command line it creates the dump file. What could be the reason for this? Thanks in advance. regards Angelo Zanetti Systems developer *Telephone:* +27 (021) 469 1052 *Mobile:* +27 (0) 72 441 3355 *Fax:*+27 (0) 86 681 5885 * Web:* http://www.zlogic.co.za *E-Mail:* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] -- Regards, Clive -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysqldump problem from PHP
Angelo Zanetti wrote: hi all, Im doing the following dump through PHP: $output = shell_exec('mysqldump '. $db_database .' '. $backup_path.$filename); It doesnt seem to work but when I run the exact same command (with appropriate values) in the command line it creates the dump file. What could be the reason for this? Thanks in advance. regards It appears that it could be because the user that runs the scripts is not allowed to. When I run them on the commandline, I run them as the root user. Is this a common problem? What would the best way be to sort this out keeping in mind security on the server? Thanks in advance. angelo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysqldump problem from PHP
hi all, Im doing the following dump through PHP: $output = shell_exec('mysqldump '. $db_database .' '. $backup_path.$filename); It doesnt seem to work but when I run the exact same command (with appropriate values) in the command line it creates the dump file. What could be the reason for this? Thanks in advance. regards It appears that it could be because the user that runs the scripts is not allowed to. When I run them on the commandline, I run them as the root user. Is this a common problem? What would the best way be to sort this out keeping in mind security on the server? If you are trying to automate backups of you database, set up a cron job. I have a shell script that dumps my databases, zips them and then sends them via FTP to a remote server. This is automatically run every 12 hours by cron. See http://en.wikipedia.org/wiki/Crontab for more info. Edward hi Edward, yes I know of CRONtabs but wont this still leave us with the user permission of running mysqldump? because essentially it will still be a PHP file to run the shell command to create the dump file? thanks No, cron will typically run as root. You don't need to involve PHP. It looks to me as if you are trying to use web scripting (PHP) to do the sysadmin on your server, for which other methods are more suitable. Edward -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysqldump problem from PHP
Edward Kay wrote: hi all, Im doing the following dump through PHP: $output = shell_exec('mysqldump '. $db_database .' '. $backup_path.$filename); It doesnt seem to work but when I run the exact same command (with appropriate values) in the command line it creates the dump file. What could be the reason for this? Thanks in advance. regards It appears that it could be because the user that runs the scripts is not allowed to. When I run them on the commandline, I run them as the root user. Is this a common problem? What would the best way be to sort this out keeping in mind security on the server? If you are trying to automate backups of you database, set up a cron job. I have a shell script that dumps my databases, zips them and then sends them via FTP to a remote server. This is automatically run every 12 hours by cron. See http://en.wikipedia.org/wiki/Crontab for more info. Edward hi Edward, yes I know of CRONtabs but wont this still leave us with the user permission of running mysqldump? because essentially it will still be a PHP file to run the shell command to create the dump file? thanks No, cron will typically run as root. You don't need to involve PHP. It looks to me as if you are trying to use web scripting (PHP) to do the sysadmin on your server, for which other methods are more suitable. Edward #1. You can run mysqldump with the same flags a the mysql command line... i.e. -u=user --password=password #2. Crons run as the user that owns the crontab, not always root. #3. Edward is right, PHP is a wonderful tool, not sure the tool was meant to do the types of things you are trying to do...unless you could fill us in with more details of what the purpose is, then we might be able to give more insight into how. -B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysqldump problem from PHP
Edward Kay wrote: Angelo Zanetti wrote: hi all, Im doing the following dump through PHP: $output = shell_exec('mysqldump '. $db_database .' '. $backup_path.$filename); It doesnt seem to work but when I run the exact same command (with appropriate values) in the command line it creates the dump file. What could be the reason for this? Thanks in advance. regards It appears that it could be because the user that runs the scripts is not allowed to. When I run them on the commandline, I run them as the root user. Is this a common problem? What would the best way be to sort this out keeping in mind security on the server? If you are trying to automate backups of you database, set up a cron job. I have a shell script that dumps my databases, zips them and then sends them via FTP to a remote server. This is automatically run every 12 hours by cron. See http://en.wikipedia.org/wiki/Crontab for more info. Edward hi Edward, yes I know of CRONtabs but wont this still leave us with the user permission of running mysqldump? because essentially it will still be a PHP file to run the shell command to create the dump file? thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysqldump problem from PHP
Angelo, as Brad says, you can pass user and password args to mysqldump from an include file. I run a php backup script via cron every night, then tar and compress and store in various dirs out of the web tree. I have the script if you'd like. It came from someone on the php-db list years ago, and I'm not in any way claiming credit for it. David On 10/23/06, Brad Bonkoski [EMAIL PROTECTED] wrote: Edward Kay wrote: hi all, Im doing the following dump through PHP: $output = shell_exec('mysqldump '. $db_database .' '. $backup_path.$filename); It doesnt seem to work but when I run the exact same command (with appropriate values) in the command line it creates the dump file. What could be the reason for this? Thanks in advance. regards It appears that it could be because the user that runs the scripts is not allowed to. When I run them on the commandline, I run them as the root user. Is this a common problem? What would the best way be to sort this out keeping in mind security on the server? If you are trying to automate backups of you database, set up a cron job. I have a shell script that dumps my databases, zips them and then sends them via FTP to a remote server. This is automatically run every 12 hours by cron. See http://en.wikipedia.org/wiki/Crontab for more info. Edward hi Edward, yes I know of CRONtabs but wont this still leave us with the user permission of running mysqldump? because essentially it will still be a PHP file to run the shell command to create the dump file? thanks No, cron will typically run as root. You don't need to involve PHP. It looks to me as if you are trying to use web scripting (PHP) to do the sysadmin on your server, for which other methods are more suitable. Edward #1. You can run mysqldump with the same flags a the mysql command line... i.e. -u=user --password=password #2. Crons run as the user that owns the crontab, not always root. #3. Edward is right, PHP is a wonderful tool, not sure the tool was meant to do the types of things you are trying to do...unless you could fill us in with more details of what the purpose is, then we might be able to give more insight into how. -B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] MySQLDump and master/slave Behavior
Howdy Guys, I have a PHP backup script running as a cronjob that has an exec(mysqldump) line followed a bit later by an exec(tar -cjf) line. The backup script runs against a slave db in the wee hours, and the master gets a continuous stream of inputs at the rate of about 18,720 per day. Obviously as the database grows in size, the script takes longer and longer to run. Right now, after about 15 months of operation, it's taking about 40 minutes to complete. But I did a test yesterday, and the mysqldump part only takes about 2 minutes to finish. Even though I've never lost data, my concern is that since master-slave syncing is blocked while the script runs, I just might lose something if there's a buffer overrun or something like that. So, Question 1 is: does mysqldump's connection to the slave db exist for the entire script execution time, or just for the length of time of its own execution? I imagine if I used mysql_connect() in the script that it would be for the entire length of the script execution, but mysqldump makes its own connection, so I'm just not sure about this. Question 2: Should I, just to be on the safe side, break out the mysqldump code into its own scipt, and run it, say, 30 minutes before the tar script? Thanks for your time, David
Re: [PHP] MySQLDump and master/slave Behavior
David Giragosian wrote: So, Question 1 is: does mysqldump's connection to the slave db exist for the entire script execution time, or just for the length of time of its own execution? I imagine if I used mysql_connect() in the script that it would be for the entire length of the script execution, but mysqldump makes its own connection, so I'm just not sure about this. Running mysqldump (an external program), the connection will only exist while mysqldump is running. PHP's connections and that of external programs are mostly unrelated. Besides, your problem isn't the connection, it's the locking that you're worried about. You can pass options to mysqldump to tell it to do as little locking as possible. That's what I do, considering that running mysqldump on a live database doesn't give you a totally up-to-date snapshot anyway. (I.e. as soon as you take a snapshot with mysqldump, it's out of date the instant there's another insert/update.) Question 2: Should I, just to be on the safe side, break out the mysqldump code into its own scipt, and run it, say, 30 minutes before the tar script? I don't think it matters. See above. I put my sql dump scripts into simple bash scripts that run from cron, but if you're more comfortable with PHP, I don't see any reason to switch nor to break it out. jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQLDump and master/slave Behavior
1. mysqldump will only keep the connection open for as long as it needs it. Once your calling script is allowed to continue mysqldump has either exited successfully or with an error, but either way the connection should no longer be active. 2. I don't think that would be a good idea. 30 minutes should buy you enough time, but if the system is getting slammed or some other unforeseeable event happens that makes the system slow down to a crawl then you run the risk of breaking your backup process. The bulk of the execution time in your script is almost certainly with your tar command. The 'j' option is telling it to use the bzip2 algorithm for compression, which is a very high compression level, but takes a long time to obtain compared to other compression algorithms. In short, I don't think anything that you're doing is going to cause any data loss as long as mysqldump isn't locking the slave database for a huge amount of time. As an aside, this isn't really PHP related so much as it is MySQL or even *nix shell commands related, you might try a MySQL list for verification. On Oct 3, 2006, at 10:29 AM, David Giragosian wrote: Howdy Guys, I have a PHP backup script running as a cronjob that has an exec (mysqldump) line followed a bit later by an exec(tar -cjf) line. The backup script runs against a slave db in the wee hours, and the master gets a continuous stream of inputs at the rate of about 18,720 per day. Obviously as the database grows in size, the script takes longer and longer to run. Right now, after about 15 months of operation, it's taking about 40 minutes to complete. But I did a test yesterday, and the mysqldump part only takes about 2 minutes to finish. Even though I've never lost data, my concern is that since master- slave syncing is blocked while the script runs, I just might lose something if there's a buffer overrun or something like that. So, Question 1 is: does mysqldump's connection to the slave db exist for the entire script execution time, or just for the length of time of its own execution? I imagine if I used mysql_connect() in the script that it would be for the entire length of the script execution, but mysqldump makes its own connection, so I'm just not sure about this. Question 2: Should I, just to be on the safe side, break out the mysqldump code into its own scipt, and run it, say, 30 minutes before the tar script? Thanks for your time, David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQLDump and master/slave Behavior
On Tue, October 3, 2006 9:29 am, David Giragosian wrote: So, Question 1 is: does mysqldump's connection to the slave db exist for the entire script execution time, or just for the length of time of its own execution? exec() runs its own little mini-not-quite-shell, so as soon as it ends, the connection would, almost-for-sure, be dead, even if mysqldump itself didn't close it, which, almost-for-sure it does. You could write another cron job to send that one query to mysql to show the open connections... Or am I thinking PostgreSQL?... Well, MySQL probably has it too anyway... Run that 20 minutes into the other script, and see if the mysqldump connection looks open, if you can detect that sort of thing... Question 2: Should I, just to be on the safe side, break out the mysqldump code into its own scipt, and run it, say, 30 minutes before the tar script? The problem with the disjoint is what if mysqldump doesn't work for whatever reason? Then you tar up the wrong thing, and pretend it's OK? Gotta plan this out, if it matters. You are *probably* fine, but it's better to check on your own system than to just take whatever some goof like me says on a mailing list. It should not be too hard to test it reliably to be 100% sure. Another option to consider: Set up a whole 'nother slave, and then do your dump and backup from THAT. So you really don't CARE if you manage to screw it up, in terms of your failure-is-not-an-option stream of incoming data to the master. Your backup is at slightly higher risk of failing. You have some timing issues of maybe losing a few more transactions/inserts/whatever. But reducing risk to the master and its input stream is drastic, so probably worth considering. I understand it's common to also set up an extra slave JUST for reporting, so your Marketing guys can't bring down the whole system just because they want to play what happened and what if games by generating a cross-indexed report of every field in every table... :-) This is definitely straying into the area of things you really would better find covered on the MySQL mailing list/forum/whatever. PS [re-arranged original post, sorry] I imagine if I used mysql_connect() in the script that it would be for the entire length of the script execution, but mysqldump makes its own connection, so I'm just not sure about this. You could always use mysql_connect and then mysql_close() to manage a connection, but that would not be the fast way to get a dump in the first place, so is kind of moot. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQLDump and master/slave Behavior
Thank you Jon, Joe, and Richard. I guess I'll leave things as they are and continue to monitor daily. Fortunately, only up to 3 years worth of data needs to be kept live in the master-slave db's, so there is a limit to how much data I will have to cope with. David
[PHP] mysqldump
This is an attempt to create an backup script for my online databases. There are few things to sort out and the coding is not the most effiecient out there yet!!! I just wanted to check on what you guys think, am I going the right way, is there anything I should keep in mind? Mario Code below - ?php $host = localhost; $user = x; $password = x; $database = xx; $field = xxx; $db_link = mysql_connect($host, $user, $password) or die (error connect); mysql_select_db($database,$db_link); $query=DESC $field; $results=mysql_query($query); while ($row=mysql_fetch_array($results)) { if ($row[3]==PRI) { $thepri = $row[0]; } $thesql .= $row[0] . . $row[1]; if ($row[2]==YES) { $thesql .= default NULL; } else { $thesql .= NOT NULL; } $thesql .= . $row[5]; $thesql .= , \n; } $thecreate = CREATE TABLE . $field . _backup ( \n; $thecreate .= $thesql; $thecreate .= PRIMARY KEY ( . $thepri . )\n; $thecreate .= ) TYPE=MyISAM;; echo The CREATE STATEMENTbr; echo $thecreate; echo br; echo br; //==// // INSERT CODE ==// //==// $result = mysql_list_tables($database); if (!$result) { print DB Error, could not list tables\n; print 'MySQL Error: ' . mysql_error(); exit; } $z=1; while ($row = mysql_fetch_row($result)) { //*** //IMPROVE //echo $row[0] . \nbr; $z++; } // //MAKE THE FOLLOWING DYNAMIC $query2 = SELECT * from . $field; $results=mysql_query($query2); $m=0; while ($row=mysql_fetch_array($results)) { for ($i=0;$i=$z-1;$i++) { $x = $row[$i]; if (($i == 0) ($m0)) { $therest .= ),; } if ($i == 0) { $therest .= (; } if (!isset($x)) { $x = NULL; } else { $x = ' . addslashes($x). '; } if ($i0) { $therest .= ,; } $therest .= $x; } $m++; } $therest .= ); echo The INSERT STATEMENTbr; $theinsert = INSERT INTO . $field . _backup VALUES ; $theinsert .= $therest . ;; echo $theinsert; ?
Re: [PHP] mysqldump
* Thus wrote Marios Adamantopoulos ([EMAIL PROTECTED]): This is an attempt to create an backup script for my online databases. There are few things to sort out and the coding is not the most effiecient out there yet!!! I just wanted to check on what you guys think, am I going the right way, is there anything I should keep in mind? perhaps something like would be a whole lot easier: `mysqldump [options] db tables`; My general policy is don't revent the wheel unless it isn't round. Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysqldump
I agree with Curt, why reinvent the wheel. I mean even if you are like me and cannot access the command-line on your web server (which really really sucks) then there are still other tools that can do this very same thing. If you just want to click on a link and backup the db why not use the load data infile (of course this does not backup the database structure just the data) http://www.mysql.com/doc/en/LOAD_DATA.html. Or why not just get phpMyAdmin and upload it to your server. It already has these features plus many others, and of course the best part is it is open source http://sourceforge.net/projects/phpmyadmin/. So why take the time of reinventing the wheel? Of course this is just my dumb opinion...so you can always take it or leave it. David -Original Message- From: Curt Zirzow [mailto:[EMAIL PROTECTED] Sent: Friday, July 25, 2003 10:33 AM To: '[EMAIL PROTECTED]' Subject: Re: [PHP] mysqldump * Thus wrote Marios Adamantopoulos ([EMAIL PROTECTED]): This is an attempt to create an backup script for my online databases. There are few things to sort out and the coding is not the most effiecient out there yet!!! I just wanted to check on what you guys think, am I going the right way, is there anything I should keep in mind? perhaps something like would be a whole lot easier: `mysqldump [options] db tables`; My general policy is don't revent the wheel unless it isn't round. Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysqldump
Thanks for the replies guys but the main reason I'm doing this is because most times I don't have access to the servers, or not enough preveleges to install myadmin or any other tools. I wish we had our own server but I'm trying for a solution where you can't upload any tools and cannot access system commands. -Original Message- From: David Smith [mailto:[EMAIL PROTECTED] Sent: 25 July 2003 16:54 To: [EMAIL PROTECTED] I agree with Curt, why reinvent the wheel. I mean even if you are like me and cannot access the command-line on your web server (which really really sucks) then there are still other tools that can do this very same thing. If you just want to click on a link and backup the db why not use the load data infile (of course this does not backup the database structure just the data) http://www.mysql.com/doc/en/LOAD_DATA.html. Or why not just get phpMyAdmin and upload it to your server. It already has these features plus many others, and of course the best part is it is open source http://sourceforge.net/projects/phpmyadmin/. So why take the time of reinventing the wheel? Of course this is just my dumb opinion...so you can always take it or leave it. David -Original Message- From: Curt Zirzow [mailto:[EMAIL PROTECTED] Sent: Friday, July 25, 2003 10:33 AM To: '[EMAIL PROTECTED]' Subject: Re: [PHP] mysqldump * Thus wrote Marios Adamantopoulos ([EMAIL PROTECTED]): This is an attempt to create an backup script for my online databases. There are few things to sort out and the coding is not the most effiecient out there yet!!! I just wanted to check on what you guys think, am I going the right way, is there anything I should keep in mind? perhaps something like would be a whole lot easier: `mysqldump [options] db tables`; My general policy is don't revent the wheel unless it isn't round. Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysqldump
Thanks for the replies guys but the main reason I'm doing this is because most times I don't have access to the servers, or not enough preveleges to install myadmin or any other tools. I wish we had our own server but I'm trying for a solution where you can't upload any tools and cannot access system commands. Curt's suggestion does not require command-line access - the backtick operator is a shorthand for exec() or passthru(), and is a language construct of PHP. So yeah, don't reinvent the wheel. http://php.net/manual/en/language.operators.execution.php - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysqldump
Sorry to be a stickler... but _technically_ the backtick is shorthand for shell_exec(). exec and passthru are a little different. Mike Migurski wrote, On 2003/Jul/25 11:12 AM: Thanks for the replies guys but the main reason I'm doing this is because most times I don't have access to the servers, or not enough preveleges to install myadmin or any other tools. I wish we had our own server but I'm trying for a solution where you can't upload any tools and cannot access system commands. Curt's suggestion does not require command-line access - the backtick operator is a shorthand for exec() or passthru(), and is a language construct of PHP. So yeah, don't reinvent the wheel. http://php.net/manual/en/language.operators.execution.php - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysqldump
just make a php file with system calls in it to do mysqldump how secure that is is a different question - Original Message - From: John Taylor-Johnston [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 10:43 PM Subject: [PHP] mysqldump Anyone do MySQLDump using PHP ? http://www.mysql.com/doc/en/mysqldump.html My code is: mysqldump -u ** -p ** -A /home/mybackups/dump_all.sql I would like to pull it off using PHP, remotely. $date = date (Ymd); $to_path = /home/MyBackups/$date/dump_all.sql; mysqldump -u ** -p ** -A $to_path; mysqldump is not PHP?! John -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.458 / Virus Database: 257 - Release Date: 2/24/2003 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysqldump
Anyone do MySQLDump using PHP ? http://www.mysql.com/doc/en/mysqldump.html My code is: mysqldump -u ** -p ** -A /home/mybackups/dump_all.sql I would like to pull it off using PHP, remotely. $date = date (Ymd); $to_path = /home/MyBackups/$date/dump_all.sql; mysqldump -u ** -p ** -A $to_path; mysqldump is not PHP?! John -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] MYSQLDUMP
mysqldump --opt -u username -p password databasename filename.sql Try mysqldump --help for additional options, or the MySQL manual. Robert Zwink -Original Message- From: TopFive [mailto:[EMAIL PROTECTED]] Sent: Tuesday, May 08, 2001 5:06 PM To: [EMAIL PROTECTED] Subject: [PHP] MYSQLDUMP When I attempt to backup my database using MYSQLDUMP, I get repeated syntax error messages from MySQL. This is driving me nuts. I've even attempted the simplest form of the command I can muster: mysqldump mydatabasename dump.sql; Am I overlooking something dreadfully obvious here? Chris W. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] MYSQLDUMP
When I attempt to backup my database using MYSQLDUMP, I get repeated syntax error messages from MySQL. This is driving me nuts. I've even attempted the simplest form of the command I can muster: mysqldump mydatabasename dump.sql; Am I overlooking something dreadfully obvious here? Chris W. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] MYSQLDUMP
you should be supplying a password...what's the error? -jack -Original Message- From: TopFive [mailto:[EMAIL PROTECTED]] Sent: Tuesday, May 08, 2001 5:06 PM To: [EMAIL PROTECTED] Subject: [PHP] MYSQLDUMP When I attempt to backup my database using MYSQLDUMP, I get repeated syntax error messages from MySQL. This is driving me nuts. I've even attempted the simplest form of the command I can muster: mysqldump mydatabasename dump.sql; Am I overlooking something dreadfully obvious here? Chris W. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]