Sponsored Content
Top Forums Web Development Confused maybe about MySQL Dump & PHP Post 302320913 by jzacsh on Friday 29th of May 2009 09:45:11 AM
Old 05-29-2009
Question Confused maybe about MySQL Dump & PHP

Hello. the purpose of my efforts right now are to get a larger script of mine (which the admin told me he'd put into cron for me) to properly back-up my MySQL database. To test out the sql back-up part (before getting the whole script into cron, and having it not work) I wanted to test it. So here's what I did:

PHP file to do my testing (on the live server)
Code:
<?php

$test = shell_exec('echo $SHELL');
echo "<pre>$test</pre>";

$output = shell_exec('sh ./sqlBack.sh');
echo "<pre>$output</pre>";
?>

Script being called by the PHP
Code:
#!/usr/local/bin/bash

# MYSQL BACKUP:
sql_bDir="./sql_backups/" #LOCATION FOR SQL BACKUPS TO LAND
sql_bName=SqlBackup_$(date "+%A")

echo "The Shopping Cart's database backup will be in $sql_bDir and will be named $sql_bName" #NOTICE OF DATABASE BACKUP
mysqldump -uNAME -pPASS --opt DBASENAME > $sql_bDir$sql_bName.tgz

just for testing, both these files were set to 777 on the server. The output from the PHP file looks just as it should, but then I find the ./sql_backups/ directory empty. I tried the username, password and database of the last line of that script in both capital letters and lower case (read somewhere that capitals works better.. anyways). I'm not experienced with php/mysql.. I found the syntax for that mysqldump line in an article.

Thanks in advance for all your help!!
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Linux/Unix/PHP/MySQL & servers?

Hello everyone! First I would like to say that I am very glad that I found this forum, and by some of the posts I have viewed, I see that I can learn a lot from you all! Secondly, I know next to nothing about Linux/Unix (gotta learn sometime right?) and need some assistance. I am a... (5 Replies)
Discussion started by: kolton
5 Replies

2. UNIX for Dummies Questions & Answers

PHP & Apache & MySQL install how-to ?

how do i install php & mysql with apache on suse linux ??? apache was installed and configured when i installed linux. all its files are in different folders. e.g http files in usr/local/httpd/htdocs/ and its configs are in etc/httpd/ so how do i install php and get it to work with apache and... (4 Replies)
Discussion started by: perleo
4 Replies

3. Shell Programming and Scripting

PHP & MySQL: sort desending and print

How do i get php to sort the times in a table and print order desending. eg: in the table i have: 02:60.00 02:70.00 02:20.00 02:50.00 in that order in a table how do i get php & mysql to print... (1 Reply)
Discussion started by: perleo
1 Replies

4. Shell Programming and Scripting

restore mysql dump file in many remote servers?

Hi all, I want to restore DB file in many mysql servers, i already using script for sending the dumpfile in all servers, but it's just annoying if i have to restore the dumpfile in all servers, i want just execute 1 script, and will restore in all remote mysql servers. I make script but not... (2 Replies)
Discussion started by: blesets
2 Replies

5. Shell Programming and Scripting

how to break mysql dump sql file

Hi folks I have mysql dump which having insert queries, i want to break that file when 10 complete "INSERTS" lines so extract that line and store in 1.sql and 2.sql and for next 10 insert lines. pls guide me how can i do that. Regards, Bash (2 Replies)
Discussion started by: learnbash
2 Replies

6. Web Development

[php] webpage with login & mysql-db

Hi all, What I was looking for before was a multi-user password manager, web-based! The offer of free or cheap tools of this kind is very pover. Or they are too complex (or too expensive) I'm not a web programmer but I now decided to set up a (php) website with login and based on this login... (1 Reply)
Discussion started by: thibautp
1 Replies

7. Shell Programming and Scripting

PHP read large string & split in multidimensional arrays & assign fieldnames & write into MYSQL

Hi, I hope the title does not scare people to look into this thread but it describes roughly what I'm trying to do. I need a solution in PHP. I'm a programming beginner, so it might be that the approach to solve this, might be easier to solve with an other approach of someone else, so if you... (0 Replies)
Discussion started by: lowmaster
0 Replies

8. Shell Programming and Scripting

Can't add variable to file name in mySQL dump script

I have a script (below) which works ok, but I have tried to modify it as I want to keep the older files for a restore if needed. I have tried adding a date suffix to the newly created files (second lump of code), but it doesn't seem to work. I get the error: $SOURCEDIR/p1db_$DATEVAR.sql:... (3 Replies)
Discussion started by: ojobson
3 Replies

9. Shell Programming and Scripting

Create mysql database with bash script - confused

Hi, i have the following: db="create database xxx;GRANT ALL PRIVILEGES ON xxx.* TO user@localhost IDENTIFIED BY 'password';FLUSH PRIVILEGES;quit;" mysql -u root -p$mysql_pass -e "$db" I don't understand why this is failing, it works fine when run from cmd but when is run in a bash script,... (1 Reply)
Discussion started by: ktm
1 Replies
MYSQL-STRESS-TE(1)					       MySQL Database System						MYSQL-STRESS-TE(1)

NAME
mysql-stress-test.pl - server stress test program SYNOPSIS
mysql-stress-test.pl [options] DESCRIPTION
The mysql-stress-test.pl Perl script performs stress-testing of the MySQL server. (MySQL 5.0 and up only) mysql-stress-test.pl requires a version of Perl that has been built with threads support. Invoke mysql-stress-test.pl like this: shell> mysql-stress-test.pl [options] mysql-stress-test.pl supports the following options: o --help Display a help message and exit. o --abort-on-error=N Causes the program to abort if an error with severity less than or equal to N was encountered. Set to 1 to abort on any error. o --check-tests-file Periodically check the file that lists the tests to be run. If it has been modified, reread the file. This can be useful if you update the list of tests to be run during a stress test. o --cleanup Force cleanup of the working directory. o --log-error-details Log error details in the global error log file. o --loop-count=N In sequential test mode, the number of loops to execute before exiting. o --mysqltest=path The path name to the mysqltest program. o --server-database=db_name The database to use for the tests. The default is test. o --server-host=host_name The host name of the local host to use for making a TCP/IP connection to the local server. By default, the connection is made to localhost using a Unix socket file. o --server-logs-dir=path This option is required. path is the directory where all client session logs will be stored. Usually this is the shared directory that is associated with the server used for testing. o --server-password=password The password to use when connecting to the server. o --server-port=port_num The TCP/IP port number to use for connecting to the server. The default is 3306. o --server-socket=file_name For connections to localhost, the Unix socket file to use, or, on Windows, the name of the named pipe to use. The default if /tmp/mysql.sock. o --server-user=user_name The MySQL user name to use when connecting to the server. The default is root. o --sleep-time=N The delay in seconds between test executions. o --stress-basedir=path This option is required. path is the working directory for the test run. It is used as the temporary location for result tracking during testing. o --stress-datadir=path The directory of data files to be used during testing. The default location is the data directory under the location given by the --stress-suite-basedir option. o --stress-init-file[=path] file_name is the location of the file that contains the list of tests to be run once to initialize the database for the testing. If missing, the default file is stress_init.txt in the test suite directory. o --stress-mode=mode This option indicates the test order in stress-test mode. The mode value is either random to select tests in random order or seq to run tests in each thread in the order specified in the test list file. The default mode is random. o --stress-suite-basedir=path This option is required. path is the directory that has the t and r subdirectories containing the test case and result files. This directory is also the default location of the stress-test.txt file that contains the list of tests. (A different location can be specified with the --stress-tests-file option.) o --stress-tests-file[=file_name] Use this option to run the stress tests. file_name is the location of the file that contains the list of tests. If file_name is omitted, the default file is stress-test.txt in the stress suite directory. (See --stress-suite-basedir.) o --suite=suite_name Run the named test suite. The default name is main (the regular test suite located in the mysql-test directory). o --test-count=N The number of tests to execute before exiting. o --test-duration=N The duration of stress testing in seconds. o --threads=N The number of threads. The default is 1. o --verbose Verbose mode. Print more information about what the program does. COPYRIGHT
Copyright (C) 2006, 2013, Oracle and/or its affiliates. All rights reserved. This documentation is free software; you can redistribute it and/or modify it only under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see http://www.gnu.org/licenses/. SEE ALSO
For more information, please refer to the MySQL Reference Manual, which may already be installed locally and which is also available online at http://dev.mysql.com/doc/. AUTHOR
Oracle Corporation (http://dev.mysql.com/). MySQL 01/23/2014 MYSQL-STRESS-TE(1)
All times are GMT -4. The time now is 10:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy