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).

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dannydudekAuthor Commented:
I actually read that, but this way the replication stops, and is read  only not only to users, but also to master.

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?


Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

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.

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:
Restore the network connection on the Slave.

More here: How do I prevent GRANT and REVOKE statements from replicating to slave machines?
Start the server with the --replicate-wild-ignore-table=mysql.% option.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Isn't what you're looking for?

If so, place "read_only" on a line (by itself) under [mysqld] on your slave's my.cnf
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.