Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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

share|improve this question
1  
Actually, if you have many databases, starting MySQL will not automatically put them in RAM... unless you explicitly set something like that up... which clearly you didn't... Have a look at MySQL configuration, maybe the cache sizes for InnoDB are too high or... something similar –  Radu Murzea Feb 20 '13 at 11:36
add comment

migrated from stackoverflow.com Feb 20 '13 at 12:21

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 2 down vote accepted

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 !!!

share|improve this answer
    
I had not thought of this solution. I think it might be a good solution in my case! Thank you! –  mserioli Feb 21 '13 at 7:41
    
it is not working fine for me with phpmyadmin ... mysql gone away. However I found an alternative fix, now mysql takes 10 sec to boot with 20 Gb of databases and more than 5000 tables. In my scenario the issue was a debian script: dba.stackexchange.com/questions/35092/… –  WonderLand Dec 31 '13 at 15:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.