Zend export database for backup - mysql

I want to create a cronjob for making a backup (sql dump) from my database and e-mail it to me. Setting up the cronjob and stuff works great and I'm able to use parts of my zend application :)
Unfortunately I cannot use exec() or system() on my server so now I'm looking for a way to get the same result. I searched everywhere with all possible descriptions I could think of, but without any results.
So in short:
I want to backup my databaseup
Preferably in .sql format (like export in phpmyadmin)
Using the Zend framework (so I can use my already loaded
application.ini settings for the database)
I cannot use exec() or system()
I'm completely stuck so really anything would help! Thanks in advance!

The solution by David Walsh looks like what you want:
http://davidwalsh.name/backup-mysql-database-php
A php script that retrieves the tables in a database and saves the data in a .sql file.

Related

Importing procedures in MySQL database

I was wondering if there was a way to write the code of a SQL procedure in a file .sql (or at least I think it should be .sql) and then import that procedure in my database (importing the file .sql). I would like to write the code in a separated file using an IDE like Geany because it is visually more confortable for me.
I already searched through Google but I only found ways to import (and export) in phpmyadmin, but I don't even know what it is. I am typing the code of my procedures using the terminal line, but I'd like to do this in some other ways.
Is there a way to do it?
Use MySQL Workbench.
https://www.mysql.com/products/workbench/
It's easy - clean interface.
There is also HeidSQL (https://www.heidisql.com/) and a whole lot of others.
Personally I prefer MySQL Workbench.

How to make automatic backup [daily , weekly ,...] using Java and mysql database "wamp server"?

I'm creating a javafx app with using wamp server for mysql database, how to make automatic backup even if database become large for a specific location, Or what's best practice in this case?
What can I do by java for this issue?
I would suggest to create a cron job for this.
You can either invoke mysqldump tool directly or create a script in any language to export data you want to, which requires more work, but is more flexible.
Alternatively you can search the Internet for some ready tool (like this which I just found, but didn't check if it works). I'm pretty sure you would find some, since it's pretty common thing to do.

Exported MySQL database without procedures by mistake

I've exported a database via SSH and I didn't add --routine command to export the routines.
Now I don't have any access to this database, and I have only one .sql file. is there any way to restore and find the routines through PHP code or database structures?
No, sorry, in this case I think you're out of luck. Looking at the database structure, you won't be able to figure out what a routine might have done. Likewise, looking at the PHP code is probably not going to help. If you know what the routines did (for instance, manipulate data on insert, maintenance by deleting some rows, or some such) you can work through recreating it, but that's basically reverse engineering it based on what breaks when you try to run your application.

How to use the generated script from SQL 2005 to MYSQL?

We are converting our database to MYSQL from MSSQL 2005.
Someone told me this is possible by generating a script in MSSQL using Database Publishing Wizard. I already created a script. Then by dragging it to the Query Writer in MYSQL. I am currently using SQLyog for creation of database.
How can I use that script to create a MYSQL file?
I also tried to use demo versions of converting tools but to no avail.
Please help me. =)
There is no simple or quick way to do a task like this. THe two database have differnt syntax and differnt datatypes, etc. I certainly would not trust a converting tool as you may want to make changes to fix bad design choices in SQL server to better choices in MYSQL.
Take your script and then run each section and find where it fails and then look up the correct syntax for mySQL and fix it.
Here is alink to a book you need to have for this conversion project as it wil show the syntax differnences:
http://www.amazon.com/SQL-Nutshell-OReilly-Kevin-Kline/dp/0596518846/ref=sr_1_2?s=books&ie=UTF8&qid=1330382519&sr=1-2

MYSQL Database offline use

Is there a way to use a MYSQL database without the database management system.. Like use tables offline without installing the db management system on the machine..
If there is can you please point me in the right direction?
Thank you!
As far as I know, there is no way to do this.
However, there is a portable DBMS SQLIte. It comes in different ways and can be used on other platform with different programming languages.
After reading your comment, I'm almost sure, this is what you need.
It's not that fast as MySQL I guess, but it works.
You can use The embedded MySQL Server Library to access MySQL data files without running the MySQL server.
You can setup a database to work on your localhost. This will be offline unless you setup the front-end stuff to let the internet interact with it.
What exactly do you mean "without the database management system"? You always need a way of interacting with it, even if it is offline. (Otherwise how can it work for you?)
The server side piece of the application, mysql-server, is needed at a minumum to run mysql. This server application comes with all the tools built-in to manage the instance. I doubt you can prevent installation of this.
If you've actually opened the table files in a hex or text editor, you'll see that you will definitely need the mysql application installed to make any sense of them to use them. Sure the records are all there in plain text (.myd files for myisam, the ibdata1 file for innodb tables), but it would be a complete time-waster devising a custom app to parse or update the file structure, as well as trying to tie in table structure contained in the related files for each table.