If I have a MySQL master-slave set-up and I change the schema on the master (e.g. ALTER TABLE/CREATE TABLE, etc), will those changes get replicated over to the slave?
Updating a database schema is pretty easy if you can take your application offline. You shutdown the application, create a backup of the current database schema, perform all required update operations using tools like Flyway or Liquibase, restart the application and hope that everything works fine.
Database schema changes are not popular among DBAs, not when you are operating production databases and cannot afford to switch off the service during a maintenance window. These are unfortunately frequent and necessary, especially when introducing new features to existing applications.
To change the name of the default schema, double-click the schema tab. This opens a schema editor window docked at the bottom of the application. To undock or redock this window, double-click anywhere in the editor title bar. To rename the schema, use the field labeled Name.
The answer is actually that it depends on the type of replication you are using and how your replication setup is configured.
Statement-based replication? Applying ALTER TABLE on the master? Not using any of the non-replication-safe SQL commands [1] (e.g. non-deterministic functions such as RAND() )?
CREATE and ALTER should replicate just fine.
In some situations it may be useful to stop slave; [run script on master]; [run script on slave]; start slave; An example is here[2].
[1] http://dev.mysql.com/doc/refman/5.1/en/replication-sbr-rbr.html
[2] http://dev.mysql.com/doc/refman/5.1/en/replication-solutions-diffengines.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With