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.
Related
I have table which has a few data.
name score
1 AAA 100
2 BBB 98
3 CCC 85
Now I want to make the insert sentence such as
insert into pepolescore(name,score) VALUE("CCC",85)
automatically.
Is there any command to do this or any function ? by mysql commandline or phpmyadmin.
MySQL queries can address another schema on the same MySQL Server instance by using qualified table names. See https://dev.mysql.com/doc/refman/8.0/en/identifier-qualifiers.html
But this does not work if the tables are on separate MySQL Servers. A given SQL query can only address schemas on the same server.
Here are a few workarounds:
Use mysqldump to export data from one table and then use mysql to import it to the other table on the other instance. You need to be careful not to let mysqldump output the DROP TABLE command, so read about the options here: https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html
MySQL supports a table engine called FEDERATED, where a table can function as a sort of proxy to a table on another MySQL Server. Then you can use INSERT ... SELECT syntax as if the tables were co-located on the same MySQL Server. The Federated engine has limitations, so read https://dev.mysql.com/doc/refman/8.0/en/federated-storage-engine.html and its subsections to learn more.
Use a community tool such as pt-archiver to copy data from one MySQL instance to the other. Read the manual to learn more: https://docs.percona.com/percona-toolkit/pt-archiver.html
Write your own custom code in a client application. Create two connections, one for each MySQL Server. Fetch query results from the first server, and store the resulting rows in variables in your application. Then use these rows as the tuples to insert using the second connection to the other MySQL Server. This involves writing more code, but you get a lot of flexibility.
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/
I have two databases with the same schema, name, stored procedures, same tables, same records on two different servers.
For example database test is present on following mentioned servers with everything same including data. server 1 = 123.155.12.1 and server 2 = 123.155.12.2
Now I need to update records in table on server 2 accordingly if there is any update done in same table on server 1. For this any query syntax exists..?
(excluding replication option) if yes please help me with example.
Thanks in advance!
Regards.
Aksh
Hi #Akki you could make use of the OPENQUERY option to achieve this, I am not sure if you want to perform this action for every update done on the Table in SERVER1 or if this is just a one time update.
I have one MySQL db on server A and another MySQL instance on a server B. There is a need to copy records (fastest possible) from one table to another (based on user providing ID for records that match) from server A -> B many times during the day. Is there a way to create an SQL statement to do this or data need to be extracted by some programming language (e.g. Perl, Python etc.), then store result in variables and then prepare Insert statement in order to to insert data to server B?
Servers have 2 different IPs and DBs are on 2 different ports but they are the same version of MySQL (5.6.29).
you could use the replication facilities of MySQL
I don't have enough reputation to just comment, but I think the easiest approach would be to create a view on server A with just that data that server B needs, then create a cron job on server B to periodically query the view & import the data during the day. For the job on B I would suggest you script it and create logfiles for debugging, but you could just put a mysql command in your crontab if you want it quick and dirty.
I have DatabaseA which has table Episodes
I have restored a backup of that database locally (lets call that DatabaseB) a while back to my localhost instance in SQL Server.
I f'd up Episodes.Description in DatabaseA and want to restore that by selecting Description from the one on my local instance and to match by Episodes.ID
Not sure hot to go about that and also how to reference the different server instances (DatabaseB (local vs. the server housing DatabaseA
here's the updated statement that messed up all files, I forgot to highlight the where clause, classic stupid mistake and so it updated everything with the same description:
update episode set description =
'some text here'
so I wanna do something like this assuming I have context to the live server while in management studio which is why I'm not fully qualifying the server for the first part, only for local I am (non-working pseudo cod here):
update episode set [description] = [description] from [CHICAGOLAPTOP\MSSQLSERVER].[DimeCastsDotNet].[dbo].[Episode] episodeLocal
where ID = episodeLocal.ID
You just need to create a linked server on either side and then you access it by the 4 part name.
Linked Servers
Little more efficient if you create the link at the server that is being updated.