Mysqlexport – Exporting Database with PHP
Whether you are a programmer or anyone with a website, it has happened to everyone; your databases You want to back up but you use shared hosting and you may encounter problems caused by the hosting company. your database or your databases It becomes impossible to export and back up your database. Even if you don't have such a problem, you may be managing your own server like me and find it difficult to back up many databases manually. your databases You want to have a system that will automatically back up your data.
Programmers are lazy, after all. They're people who automate or simplify everything to stay lazy. This world has seen system administrators who wrote code so that the coffee machine would start making coffee when the program was running and finish making coffee just as the program arrived. That's the kind of person I admire.
I also on my server databases to automatically back up a PHP I created the class. Cronjob I'll get rid of this problem by creating it. You can either use it for automatic backups like I did, or create a special page that backs up with a password you enter online.
I created mysqlexport to the project https://github.com/erhankilic/mysqlexport You can create your address from .
As you wish, with the following example usage your databases You can back up. Only a user with access authorization to all databases user You must do it with. Otherwise, which to the database If it has the authority, it will only back it up.
Usage Steps;
- Firstly include We include our class in our program.
- One variable We are assigning the new class we created. First in the parameter We write the path to the location to be backed up. Then, database connection address (usually localhost), username And user password parameters We write as.
- From now on, we have two options. setDatabases(array $databases) with one array we want to back up in databases we define it in the program or getDatabases() with the function databases We ensure that their names are drawn.
- Finally, export() We complete the backup process with the function.
<?php include 'Export.php'; $export = new MysqlExport\TOxport('backup', 'localhost', 'root', 'giant1'); $export->getDatabases(); $export->export();
I didn't quite understand how to continue