This is important when we are using the MySQL data backup. Backup should we do this many times so that we keep data secure, when the hard disk damage or loss of data due to the reason we do not know. Here are any posts short, how to use a simple PHP script to make backups of data in MySQL.
- $dbname = "infokomtek_com";
- $dbhost = "localhost";
- $dbuser = "root";
- $dbpass = "******";
- $backupFile = "infokomtek_com";
- $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 = "infokomtek_com" is the name of the data base that we want to backup. $ dbhost = "localhost" is the host name data base we are. $ dbuser = "root" user to access a database. $ dbpass = "******" is the password to access the databases. Depending on your settings in MySQL, sometimes the password is not necessary to connect to MySQL.
If you save this script in crontab PHP, then you can backup your data base in accordance with yours.
No comments:
Post a Comment