The Alter database processing logic of MySQL database is not as terrible as Alter table, and the processing logic is clear. First, check whether the database name is effectively called check_db_name () (table. cc: 2876) to check whether the database name is valid, call check_table_name () (table. cc: 2904) function. The check_table_name function name is misleading. It is actually used to check whether the database name is legal. 2. Check whether you have the right to modify the check_access () (SQL _parse.cc: 4715) to check whether the database exists and whether the user has the permission to modify the database. Www.2cto.com 3. Call mysql_alter_db () (SQL _db.cc: 685) to modify the database. Call the lock_schema_name () (lock. cc: 767) function to obtain the mutex lock of the schema. Call the write_db_opt () (SQL _db.cc: 313) function to recreate the db. opt file. The content recorded in the db. opt file is the content of the default character set. Then write the binlog. The above analysis shows that the business logic of the Alter database operation is relatively simple, but the function is also relatively simple. The alter database option can only modify the default charset and default collation. Author king_wangheng