export saved MySQL query with database? - mysql

I need to export my database, however when I done so and tested it by importing it again in do a different MySQL instance all my bookmarked queries were gone.
How do I export them with the database, so other people can run them by importing the database?
Is there another way?
I could just export each query as a table and have it as separate to the data base

Bookmarked queries have nothing to do with the database. It's a feature of the client. For example that standard linux mysql CLI saves all executed querys to a file name .mysql_history. Like wise whatever client it is that you are using will have a place where this queries are saved, you just need to find it.

Related

Database inaccessible when Exporting

I am exporting a MySQL database that is currently in use by an application, but when I start the process the database becomes inaccessible and the application does not work, so I had to terminate the export process to allow the application to use it again. As the application is live, I cant let it go offline. Is this a normal thing, that MySQL database doesn't work when being exported, or do I need to do something in particular to export it this way?
Are you using mysqldump? Sounds like your tables are being locked.
Are you working with InnoDB tables? If you are using mysqldump, I'd look into the --single-transaction option. That will take a snapshot, but the key thing to remember is that any data changed during the export will not be reflected in the output. It will be in the production db, just not in the export until next time.
https://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_single-transaction

Export Specific Records from MySql Workbench

I have databases in my system and also put database on web server also, so when I update my system database data I ll have to then replace or add data into web database.
but
problem is that I am doing changes in database to some specific record frequently for testing purpose.
So I want some mechanism that will used to export some specific records to sql file with insert statement.
Suppose I have made change in table tbl1 and added 10 records to it.
So right now I am manually adding or replacing whole table on web database.
So is there any mechanism in MySql or in Workbench using that I can export specific records.
Any Help for that.
The only automatic solution is to use replication, but that is probably not a good solution for your scenario. So what remains is some manual process. Here are some ideas:
Write a script that writes specific records into a dump file.
Then use a different script to load this dump file into your
target server.
If you frequently change the same records you could create a script
with insert statements that you edit for each new value and run
against both your local and your remote (web) server.

convert Access to mysql commands

One of our customer has an Access database in his own server and I need to import it to a linux server with mysql in my own server.
In other words, I need to convert Access to mysql commands (inserts basically).
I've tried the DBWScript which works fine although it does not allow to export only one table. It exports all tables. What I'm doing now is exporting all the tables to a sql file and then I filter it taking only the inserts I really need.
I'd like to know if anybody knows a software like DBWScript that can be run in console-mode and permits to export only one table from a database, because that table has a lot of rows (up to 100.000) and it has no sense to export all the other tables if I am not going to use them. That increases the conversion time a lot.
I finally used a software called "Bullzip MS Access to MySQL" and it works like a charm!
This is the author's website: http://www.bullzip.com/products/a2m/info.php
It allows yo to select the desired table and desired columns in different tables, apart from creating a batch script to automate the process.
You can try Data Import tool in dbForge Studio for SQL Server.
Open Data Import wizard, select MS Access format, specify other options and save template file. Then use this template file (*.dit) in command line mode.
You can try using tips to converting MS Access to MySQL

How to upload data from zip file to MySQL database using phpMyAdmin?

I have a client who got a zipped file that has all the database they had in the SaaS app they were using. Now, we have a similar app but our column names are different (obviously) and in some cases we have less columns. So, now i want to upload all this data to my database but i am not sure how to do it?
I run phpmyadmin on the servers.
Extract the file on your desktop.
Login to your phpMyAdmin account.
Click the Import tab.
Select the file to import, file format, ect. and click Go.
Browse through the structure of the imported database to the columns of interest. For each column, click the pencil icon to edit the column (i.e. rename it), or click the X icon to delete it.
To merge data sets, after importing the tables, you would need to run your own query in the SQL tab to merge the data sets.
That are two different tasks in one question,
phpMyAdmin is able to import ZIP-files directly – you don't need to extract them on your local machine. Also be aware of max upload sizes and maximum script execution times, when importing huge database dumps.
To map an existing database to another structure involves a lot of manual work, like renaming tables and columns and copying data from on table to another.I would suggest, you import the old/original database to some "working copy" database and have your new database separate. That way you can use MySQL-features (INSERT INTO new_db.YX … SELECT XY_a FROM old_db.XY) to copy the data where it should go.
Well first you need to take a look at the data files and see how the columns/tables differ. After you sort that out you can go about about figuring out how it insert the data. If the files are large and there are quite a few i wouldnt use phpmyadmin. I'd ssh into the box and use the command line client or set the DB up for remote access and use a local copy of the client.
If youre lucky you won't have to do any processing on the data and you just map values from the old columns to the new columns as part of you LOAD DATA INFILE statement. Whatever you do youll want to test all this on a dummy db(s) first before you go running it in a live environment.

How to export data from odbc?

I'm a newbie for odbc. Right now I'm connecting odbc successfully to mysql. Is there any way to easily export datatable to the local? (For me, access is not an option. And I have tried odbc explorer which is good but there's only free trial version. Also I have tried Mysql workbench, which is too dangerous since it can easily wipe out all data in the source.)
Hope to have some suggestions from you guys, cheers.
Most databases I know have some import/export utilites. Such tools exports both schema (tables descriptions, triggers, user functions etc) and data. Of course they are made to work with the same database engine or to move data to newer version of database engine. Mysql have such tools too: look at mysqldump
From ODBC you can obtain some information about schema: table names, column names, column types, primary key etc, and that information should be enough to make simple utility to export data to local files, for example into .csv files. Simply read info about tables using SQLTables(), then for each table do SELECT * FROM table and write result into .csv file.