I have to transfer data from old MySQL database to new MySQL database in another server in real time , and in new DB some columns might change, e.g. there is table named businesses with (room_no, location, building_no, floor_level) columns, but in new DB all those columns will go into column named full_address, others table will have transformation like that, Could you please advise me which technology to use,
我必须实时地将数据从旧MySQL数据库传输到另一台服务器中的新MySQL数据库,而在新数据库中,某些列可能会发生变化,例如:有一个名为business的表(room_no,location,building_no,floor_level)列,但是在新的DB中,所有这些列都将进入名为full_address的列,其他表将有这样的转换,你能告诉我使用哪种技术,
I've researched and found MySQL replication which is cool, but there is no option for transformation (as i know), I use PHP(Laravel) for my project.
我研究并发现MySQL复制很酷,但没有转换选项(据我所知),我使用PHP(Laravel)作为我的项目。
2 个解决方案
#1
1
This can be done with help of any programming language, since you are using PHP, you can do it with PHP, all you need to do is when you are saving the data in old database, at that time you can after inserting data to old DB,you can close the connection of old DB and create new connection to the new DB and convert the data as per new DB structure and insert in new DB. This way you can have real time data in both the Databases, in 2 different databases.
这可以在任何编程语言的帮助下完成,因为你使用的是PHP,你可以用PHP来完成,所有你需要做的就是当你在旧数据库中保存数据时,那时你可以在将数据插入旧数据库之后DB,您可以关闭旧数据库的连接并创建与新数据库的新连接,并根据新数据库结构转换数据并插入新数据库。这样,您就可以在两个不同的数据库中的数据库中获得实时数据。
Hope this helps.
希望这可以帮助。
#2
1
In that case you have to make functions in laravel (php) that read the data from old tables and according to your requirement do the merging of data and then insert it into the new tables.
在这种情况下,你必须在laravel(php)中创建函数,从旧表中读取数据,并根据您的要求进行数据合并,然后将其插入新表中。
And do it wisely, as there is some chance of data losing if the datatype
of both column do not match. You have to handle such cases at your end.
明智地做到这一点,因为如果两列的数据类型不匹配,则有可能丢失数据。你必须在最后处理这种情况。
#1
1
This can be done with help of any programming language, since you are using PHP, you can do it with PHP, all you need to do is when you are saving the data in old database, at that time you can after inserting data to old DB,you can close the connection of old DB and create new connection to the new DB and convert the data as per new DB structure and insert in new DB. This way you can have real time data in both the Databases, in 2 different databases.
这可以在任何编程语言的帮助下完成,因为你使用的是PHP,你可以用PHP来完成,所有你需要做的就是当你在旧数据库中保存数据时,那时你可以在将数据插入旧数据库之后DB,您可以关闭旧数据库的连接并创建与新数据库的新连接,并根据新数据库结构转换数据并插入新数据库。这样,您就可以在两个不同的数据库中的数据库中获得实时数据。
Hope this helps.
希望这可以帮助。
#2
1
In that case you have to make functions in laravel (php) that read the data from old tables and according to your requirement do the merging of data and then insert it into the new tables.
在这种情况下,你必须在laravel(php)中创建函数,从旧表中读取数据,并根据您的要求进行数据合并,然后将其插入新表中。
And do it wisely, as there is some chance of data losing if the datatype
of both column do not match. You have to handle such cases at your end.
明智地做到这一点,因为如果两列的数据类型不匹配,则有可能丢失数据。你必须在最后处理这种情况。