HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Mysql: disable unused schemas

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
mysqlschemasdisableunused

Problem

I have many schemas on mysql instance running on my development pc. I've noticed that mysql is taking a large amount of ram and cpu time.

Is there a way to "disable" schemas of project I'm not working for?

I like to avoid to drop schema and then re-import when I need it. I'm searching to a way for just disable them or something similar!

Thanks
Marco

Solution

Every subfolder under datadir is considered fair game to be registered as a database. You could just mysqldump that entire database and then drop the database.
SUGGESTION

If you have to leave the database present but inaccessible, here is something radical you can try:

EXAMPLE

Suppose you have a database called mydb and you want to disable access to it. Go into the Linux OS and do the following:

chown -R root:root /var/lib/mysql/mydb


That's it. Since /var/lib/mysql/mydb would be no longer owned by the Linux mysql user, mysqld cannot access anything in that folder.

If you want the database accessible again, just do the reverse:

chown -R mysql:mysql /var/lib/mysql/mydb


Now, if you are dealing with Windows, try shutting down mysql with

net stop mysql


You could then

  • Rename the folder from mydb to #mydb something mysqld would not like



  • Run attrib +a against that folder



  • Just about anything that can deny read/write access to the Windows folder



Finally, start mysql back up

net start mysql


Give it a Try !!!

Code Snippets

chown -R root:root /var/lib/mysql/mydb
chown -R mysql:mysql /var/lib/mysql/mydb
net stop mysql
net start mysql

Context

StackExchange Database Administrators Q#35092, answer score: 2

Revisions (0)

No revisions yet.