I hate the checking permissions issue.
You may have to disable key checks before the DROP DATABASE
SET unique_checks = 0;
SET foreign_key_checks = 0;
SET GLOBAL innodb_stats_on_metadata = 0;
DROP DATABASE db_madeintouch;
SET GLOBAL innodb_stats_on_metadata = 1;
SET foreign_key_checks = 1;
SET unique_checks = 1;
UPDATE 2013-04-15 18:04 EDT
I just noticed you have innodb_file_per_table OFF. What gives ?
- You currently have all the InnoDB data and the corresponding index sitting in a single file.
- Any CREATE TABLE statement must make data dictionary updates and look for space (small but annoying in this instance)
- Internal Fragmentation of ibdata1
- Dropping a table means scanning the table and its indexes for availability to lock. With data and index pages possibly fragmented, this takes spindles, seek time, and latency.
- See Pictorial Representation of ibdata1 to see everything that goes into ibdata1
Recommendation : Remove all Data and Index Pages from ibdata1
This will give ibdata1 a breather to handle just data dictionary and MVCC management. In addition, ibdata1 will stay rather lean and mean and can be read more quickly.
You will need to perform the InnoDB Infrastructure Cleanup. I wrote out all the steps back on October 29, 2010 in StackOverflow.
UPDATE 2013-04-22 08:10 EDT
Three suggestions
SUGGESTION 1 : I just noticed something else. You are using an ancient version of MySQL (5.0.45). You should think about upgrading to MySQL 5.6.11 as it performs significantly faster that MySQL 5.5 and way faster than MySQL 5.0.
SUGGESTION 2 : You should also go ahead and implement the InnoDB Infrastructure Cleanup.
SUGGESTION 3 : You should also check the disk itself. If the data is sitting on a RAID10 set, one of the disks may have an issues. Check the disk controller's battery as well because it can slow down disk caching and affect read performance.
QUESTION #1
Why are there different levels of MySQL collation/charsets?
ANSWER TO QUESTION #1
There are two good reasons for different character sets and collations
Reason #1 : Disk Space
When you run this query
SELECT
maxlen,
GROUP_CONCAT(CHARACTER_SET_NAME) CharSets,
COUNT(1) CharSetCount
FROM information_schema.character_sets
GROUP BY maxlen\G
You get this:
mysql> SELECT
-> maxlen,
-> GROUP_CONCAT(CHARACTER_SET_NAME) CharSets,
-> COUNT(1) CharSetCount
-> FROM information_schema.character_sets
-> GROUP BY maxlen\G
*************************** 1. row ***************************
maxlen: 1
CharSets: cp1257,cp850,binary,koi8r,latin2,ascii,tis620,koi8u,greek,armscii8,keybcs2,macroman,latin7,cp1251,cp1256,dec8,hp8,geostd8,latin1,swe7,hebrew,cp1250,latin5,cp866,macce,cp852
CharSetCount: 26
*************************** 2. row ***************************
maxlen: 2
CharSets: big5,cp932,sjis,gbk,ucs2,euckr,gb2312
CharSetCount: 7
*************************** 3. row ***************************
maxlen: 3
CharSets: eucjpms,ujis,utf8
CharSetCount: 3
*************************** 4. row ***************************
maxlen: 4
CharSets: utf16,utf32,utf8mb4
CharSetCount: 3
4 rows in set (0.00 sec)
mysql>
Some character sets have a Maximum Length of 1 byte to represent a character. Other need more. Give this information, you may want to refrain from using the eucjpms, ujis, utf8, utf16, utf32, utf8mb4 character sets so that VARCHAR and TEXT data takes less space on disk.
Reason #2 : Internationalization
Characters Sets Each Come With One or More Collations to cover a variety of Languages
When you run this query
SELECT
A.CHARACTER_SET_NAME,
GROUP_CONCAT(COLLATION_NAME) Collations,
COUNT(1) CollationCount
FROM
information_schema.character_sets A
INNER JOIN information_schema.collations B
USING (CHARACTER_SET_NAME)
GROUP BY A.CHARACTER_SET_NAME\G
You will see that some Characters Sets have with multiple collations for Different Parts of Europe. Chinese, Japanese, Greek, and parts of Asia Minor and Scandinavia are also available.
QUESTION #2
Should you always ensure your PHP connection matches the charset of the database you're working on?
ANSWER TO QUESTION #2
SCENARIO
You are driving at 3:00 AM. You are the only driver on the road. You come to an intersection. You have the red light.
Question : Do you stop or go through the red light?
Answer : Depends on the neighborhood
- Safe neighborhood ?
- Some abide by the law, stop at the red, and wait for green.
- Some chance it and go through
- Bad neighborhood or new to the area ?
- Some abide by the law, stop at the red, and wait for green AT THE RISK OF A CARJACKING
- Some chance it and go through to AVOID OR REDUCE RISK OF A CARJACKING
- Assume the worst and find another route
How does this apply?
You should err on the side of caution. You should always check the charset beforehand because you do not know the neighborhood (client program, internet browser) the PHP connection will be entering and if there is a risk of a carjacking (putting invalid data into the database, requesting too much data for retrieval).
QUESTION #3
If you can have different tables that use different character sets do you just use SET NAMES or mysql(i)_set_charset to switch?
ANSWER TO QUESTION #3
By all means
QUESTION #4
If you have a table that has multiple charsets how do you manage that since the connection can only use one charset at a time?
ANSWER TO QUESTION #4
You may have to shift character sets with the DB Session. Here are the settings that can be changed at the session level:
Please set these carefully before reading from and writing to the database. It would also be wise to store the character set name and collation in the same table you will be accessing.
Best Answer
Think about it:
latin1
latin1
If data coming from the OS or from the connection is
utf8
, how is mysqld going to treat it?Rather than guessing or hoping for the best, you could change the incoming character set behavior. With the exception of
information_schema
andmysql
, take all your databases and set the default character set toutf8
:If you have a specific colllation to go with it, do this:
Here are the collations to choose from:
You could also run
To see the individual charset of a database run this:
As for the settings, you could try this:
Add the lines to
my.cnf
then restart mysql
I discussed this back on Aug 01, 2011 : Character Set Encoding in a Table
CAVEAT (For MySQL DB Servers in Windows)
These commands
do not work in the Windows Version of MySQL because of the way Windows locks files. The file needed is called
db.opt
which is located in the database subfolder indatadir
.You may have to do the following:
EPILOGUE
No matter what you do, please perform any changes on a Dev/Staging Server to see if you get the desired effects
UPDATE 2012-12-05 11:00 EDT
Your Questions
To guarantee the proper treatment of the data, you may want to make sure you have apples-to-apples. Data prepared as one charset and loading it into a table with the database possibly aligning the data as if it sees another charset would probably not display the data with the charset mysqld sees when retrieved and sent back to a DB Connection. Try loading the database on a Dev/Staging Server and experiment with setting default charsets.
This would depend on the OS version of the MySQL Binary. Windows versions may have
latin1
while Linux Versions may useutf8
.