[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6744
  • Last Modified:

How to make MySQL Slave "read-only"?

Hi All,

I have setup master-slave MySQL replication, which works great, however I would like to make sure, that slave database cannot be modified. Is there any way i could make it "read-only"?

I was thinking about changing users permission on the slave, however that could cause break in replication (the entire server is replicated).

0
dannydudek
Asked:
dannydudek
  • 3
  • 2
1 Solution
 
adrpoCommented:
0
 
dannydudekAuthor Commented:
I actually read that, but this way the replication stops, and is read  only not only to users, but also to master.
0
 
adrpoCommented:


Ok, let me undestand what you want here. Let's see if I understand correctly:
1. Master - Slave replication
2. Master push all the queries to Salve
3. You want to block the update/delete/insert/create to the Slave

But then this is not replication anymore!
If the Master gets an insert then it pushes that to the Slave and
the slave rejects it. Then the databases are not the same anymore.
The replica contains less data.

Or you want  to just block update/delete??!
But then again your replica is not the same as the one you have on master!!
So which one is it?

Cheers,
za-k/

0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
dannydudekAuthor Commented:
I want slave to be up to date with master, but i want to make sure that users cannot modifiy anything on the slave.
0
 
adrpoCommented:

Ok, more questions:
You mean users connected to the Slave, because if you mean users
connected to the master, then via the replication they will modify
the Slave.

If you want to not let anyone connect to the mysql Slave, do this.
Kill the network connection to the Master.
Revoke any grant acces in your Slave's mysql.user table
Then start the server with:
--replicate-wild-ignore-table=mysql.user
Restore the network connection on the Slave.

More here:
http://dev.mysql.com/doc/refman/5.0/en/replication-faq.html#qandaitem-15-3-4-9
15.3.4.9: How do I prevent GRANT and REVOKE statements from replicating to slave machines?
Start the server with the --replicate-wild-ignore-table=mysql.% option.

Cheers,
za-k/
0
 
Mark-austinCommented:
Isn't http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_read_only what you're looking for?

If so, place "read_only" on a line (by itself) under [mysqld] on your slave's my.cnf
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now