Synchronization one table from general database to another database on another servers - mysql

I need to have one "General login database", with few columns (ID, Pass, User, IP).
Users came to site, enter their data (they can chage password\username, and they ip can be changed), all this changes goes to "General Login DB".
And i have 2 another servers, with same database "Login Database 1" "Log.DB 2" and maybe few more (5 or 10)... they have exactly same columns name (id, pass, user,ip) and few more speciefic wich must stay only on (log.db2, 3, 4, 5 etc database) and they dont exist on General DB.
So my questions is how to Link few database.table to another database.table, and keep it "Up-To-Date" online, or how to make automatic changes (Insert\Update\Delete) in them, after changes (ins, upd, del) came to General Login DB.
Image only show direction that i want, and not perfect with structure.
I am interested in 2 variants, if it works on One server, and second variant, if it works on 2-3-4-5 servers.
UPDATE: i found some info, about "Replication"
https://habrahabr.ru/post/56702/ (you can translate it, or google "Replication mysql" but there only info about 2 identical Database, but my goal is only make identical few columns in one table.

Do can arrived this with the Standard Replication from MySQL / MariaDB. There you can select wich tables / Schemas are replicated to the slaves. Any Slave connected to the Master.
see: https://mariadb.com/kb/en/mariadb/standard-replication/

Related

Mysql replicate two databases

I have a database setup online where I take user registrations and provide them a pass to enter the event ( people gathering), Now at the event I also have to perform user registrations, situation is internet is not always stable at the event so I am considering to setup database offline, I found some guides on mysql replications but not getting full picture if its possible the way I want.
At the event I will setup database at my localhost and register users offline, also take new registrations online ( on other server hosting a copy of same database online), users table has an autoincremental index which is going to be a huge problem to sync both databases using mysql replication, when both servers will add a record to the same table ,it will assign the same index id to both databases. Is there something I can do to avoid this issue.
Well, master-master replication does exist, and may suit your purposes, but it has some drawbacks.
I think you should consider taking registrations in a different form when on-site, then insert them into your main database when you get home. This is a pretty common way to do things.
If you really need to it with MySQL, come up with a "merge" tool that can re-create the users created off-site, on demand; as you pointed out, you'll need to account for different auto-increment IDs, but that's not necessarily an actual problem. It just needs to be dealt with.
If your primary concern is that you have 2 systems that need to generate id that are unique from each other without coordination, there's a couple of things you can:
Use auto_increment_increment and auto_increment_offset. Simply put 1 of your 2 servers might use even id's and the other one odd ones.
Use a different key, maybe a natural key (email address?)
Use something like a UUID (or GUID if you're in the microsoft world. They're really the same thing).
you can dump the database from server to local from terminal like below.
Run command : mysqldump -h hostname -u username -ppassword databasename > C:\path_to_file

How to achieve redundancy between 2 tables of different databases?

First of all I'd like to start saying that I've checked these two questions:
Sync 2 tables of different databases - MySQL
How to synchronize two tables of different databases on the same machine (MySql)
But while similar they are not what i need.
I have 2 databases in the same server.
Db1 and Db2
Both databases have the exact copy of a single table called "user":
userid
login
name
lastname
password
level
How can I achieve some sort of redundancy between these two tables in different databases?
If db1.user gets a new record then db2.user has to have that record, if a record is modified then the other one is modified and if deleted the then the other one gets deleted too.
To be more specific, db2.user needs to be a reflection of db1.user using triggers.
EDIT: there is this question: Mysql replication on single server and that is not even remotely close to what i want to do. I updated a little bit at the very end of what i previously posted with how I'd like to achieve this thanks to a suggestion.
As proposed you can use triggers as stated in this standard documentation.
You define AFTER INSERT,AFTER UPDATE and AFTER DELETE triggers on db1.user and within this trigger you have the NEW.object to pass the information into the db2.user table.

Use 1 table in 5 mysql server and connect servers togther

hello this is my mysql table
table_clients
client_id
client_username (UNIQUE)
client_password
now i want to get 5 servers and install mysql on each server and use this table on each 5 servers.
my question is: is there any way that all 5 servers connected to each other (by 1 request) and converted to 1 big server? i mean if there is one user with username (hiworld) in server 2, can not create it this user again in other servers !. (connect all 5 server with same table together and make them 1 big server) .. is it possible?
my queries are too big (2-3 bilion) and i want to share them between 3-4 servers but (make servers united) like when use 1 server )
How to create linked server MySQL
"Cross Linked Servers" a functionality that exists on Ms Sql is the type of thing your looking for.
You would need to do some sort of insert trigger that checked to see if the name existed on the other server.
But this will be slow plus there is a risk of two servers getting the same name at the same time and allowing the insert because when it checked the other name was not already there.
No real good way of doing this. One idea may be to have only one master table for the table_clients. Make it a master to slave relationship. Any time you have to do an insert you insert to the master table/database, then copy that data to the slave instances. But you would still have to cross link the servers for this to work. What you are describing would require waiting on 5 servers to tell if the name has already been used. This way you only have to check on one server.

i want replica of my database that is to be use by another database

i have my database database1 for my company.
i want to create another database for client's company.the client's company requirement is same as ours.so that i can use my database1 for creating their database.
In database1 there is a tables which i want to use in client's company database. so please tell me how i can reduced the redundancy by using only database1 for my company and client's company too??? or do you think i want to make replica of database1??? if i have to make replica of database1,then how i can make it in mysql???
please suggest me how i can use one Database structure for other database.
i need your help.please tell me the right way of doing these.
If there is no separate server requirement from your client then you can do as per below-
I am assuming that some master tables will be always same for you as well your client as you mentioned that both have same kind of project, so create 3 databases on same server-
master_db : It will keep generic information tables, which will be used by you as well your client and should keep same information for both-
client_db : It will store tables those keep information for client like client's order can be different, need logs those will be different etc.
your_db : It will keep tables those you need only.
Note: Further it will depend how you are using db/tables in your code. Multiple DB setup will work for you or not. As per me it should not be any issue.

"Copying" third party databases into central mySQL and keeping mySQL up to date

I have a question which is what I believe to be quite complicated and would like to see what experts like yourselves think about my solution.
Problem:
I am collecting data from a number of third parties into a central mySQL database. The third parties can have any database product (mySQL, Oracle, postgreSQL, etc). I will need to perform two tasks, which are the following:
On first start, replicate the full database onto the central mySQL database
Incrementally update the central mySQL database as changes are done to the third party database
Proposed solution:
I intend on creating database crawlers in C# per third party database. So say for example one of the third parties has an oracle database. I intend on creating a class which will query an oracle database for its definition and data and programmatically create sql queries to be executed by the central mySQL database.
ex: create table XYZ (id1 int, id2 int), Insert into XYZ values(1,2), etc.
Here is the problem which is giving me the greatest grief. Id like to know if anyone has ever queried a database to effectively ask it "what are your latest changes", or what are your changes since dd-mm-yyyy hh:MM:ss. By changes I mean both data changes and data definition changes. ex: add new column, update a [row][column] value, insert new row, etc.
if you have access onto the database writer program, couldn't you just inject a code which generates / writes the data to the central database (aka a LOGGER)?
I mean that you could make your central database as a "LOGGING Database".
If for some reason the third part database needs database rollback, you could just take the command from current timestamp to timestamp-rollback_days and change from INSERT to DELETE, DELETE to INSERT, etc.
That way, your database won't be suffering much because you replicate whole DB :)