SQL database backup and restore on user id - mysql

I have a database which contains details about user information.The database contains 20 tables with users specific details.Every table contains user foreign key. I want to be able to backup specific user data from the database and restore the backup. Is it possible to restore the backup on a different database that has same tables. I am working on this but not able to find a documentation or article on this. If you could help me on this if doing this is possible. Thank you in advance

You need to write some SQL to export the data. You can use a number of techniques for example:
Gather data using views, stored procedures or a combination of both.
Export data using linked servers, import export or SSIS.
There is no backup and restore functionality for a subset if data.
(p.s. This is for SQL Server. You have three different database engines in your tags.)

Related

How to find a speicifc entry in tables in a database mysql?

I have a database wordpress consisting a lot of tables. I am looking for a certain entry 20.22.31.44. What is the best way to return the table and column if this entry exists?
You can dump your database data (SQLDump) into a file and search through it's content.
You may also use a Database Management system (i.e. Workbench, PHPMyAdmin) to perform that global search for you. See related.

Querying data from 2 MySQL Databases to a new MySQL database

I want to query data from two different MySQL databases to a new MySQL database.
I have two databases with a lot of irrelevant data and I want to create what can be seen as a data warehouse where only relevent data should be present coming from the two databases.
As of now all data gets sent to the two old databases, however I would like to have scheduled updating so the new database is up to speed. There is a key between the two databases so in best case I would like all data to be present in one table however this is not crucial.
I have done similar work with Logstash and ES, however I do not know how to do it when it comes to MySQL.
Best way to do that is create a ETL process with Pentaho Data Integrator or any ETL tool. Where your source will be two different databases, in the transformation part you can remove or add any business logic then load those data into new database.
If you create this ETL you can schedule it once a day so that your database will be up to date.
If you want to do this without an ETL than your database must be in same host. Than you can just add database name just before table name in query. like SELECT * FROM database.table_name

Accesing data from one mysql database to another in MYSQL Workbench

I have two different databases. I have to access data from one database and insert them into another ( with some data processing included, it is not only to copy data ) Also, the schema is really complex and each table has many rows, so copying data into schema in the second database is not an option. I have to do that using MySQL Workbench, so I have to do it using SQL queries. Is there a way to create a connection from one database to another and access its data?
While MySQL Workbench can be used to transfer data between servers (e.g. as part of a migration process) it is not useful when you have to process the data first. Instead you have 2 other options:
Use a dedicated tool you write yourself to do that (as eddwinpaz mentioned).
Use the capabilities of your server. That is, copy the data to the target server, into a temporary table (using dump and restore). Then use queries to modify the data as you need it. Finally copy it to the target table.

export tables of mysql database for insertion into a different database

I have a wordpress instance running on my localhost. In order to move this to another server, I'd like to export the contents of this database to an sql file. However, I don't have the permission to create new databases, I have an existing database in which I'd like to insert the tables and all the rows inside them. Is there a way to tell phpmyadmin to export the data in such a way that everything will be inserted into this new database? Or would it be better to just do a find/replace inside the sql file?
In fact, if you select the database in phpmyadmin, it shows all the tables contained. If you choose to export at that stage, it will export by default (actually depends on its version) all the tables structure and data without database creation. Additionally, it does give you the option of exporting only the data.

Combine several mssql database to one mysql with php

We are handling a data aggregation project by having several microsoft sql server databases combining to one mysql database. all mssql database have the same schema.
The requirements are :
each mssql database can be imported to mysql independently
before being able to import each record to mysql we need to validates each records with a specific createrias via php.
each imported mssql database can be rollbacked. It means even it already imported to mysql, all the mssql database can be removed from the mysql.
we would still like to know where does each record imported to the mysql come from what mssql database.
All import process will be done with PHP .
we have difficulty in many aspects. we don't know what is the best approach to solve our problem.
your help will be highly appreciated.
ps: each mssql database has around 60 tables and each table can have a few hundred thousands .
Don't use PHP as a database administration utility. Any time you build a quick PHP script to transfer records directly from one database to another, you're going to cause yourself a world of hurt when that script becomes required for production operation.
You have a number of problems that you need solved:
You have multiple MSSQL databases with similar if not identical tables.
You have a single MySQL database that you want to merge the data into.
The imported data must be altered in a specific way before being merged.
You want to prevent all duplicate records in your import.
You want to know what database each record originally came from.
The solution?
Analyze the source MSSQL databases and create a merge strategy for them.
Create a database structure on the MySQL database that fits the merge strategy in #1, including all the new key constraints (like unique and foreign keys) required for the consolidation.
At this point you have two options left:
Dump the data from each of the source databases into raw data using your RDBMS administration utility of choice. Alter that data to fit your merge strategy and constraints. Document this, and then merge all of the data into your new database structure.
Use a tool like opendbcopy to map columns from one database to another and run a mass import.
Hope this helps.