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 want to change the "Information_schema" database name to "some_thing_else".

Is this possible? If so, how can I do so?

As a developer knows about structure and a hacker also. How can we protect from hackers, with sql injection? I'd some old big sites developed with PHP and mysql instead of with PDO library. See this -

Original URL - ABC.php?id=1 Injected URL - ABC.php?id=1 and 1=2 union all select 1,2,group_concat(table_name),4,5,6,7,8,9,10,11,12 from information_schema.tables where table_schema=database()--

So, I would like to customize the name of two table/memory whatever, one is information_schema and mysql. It should be possible.

share|improve this question

closed as off-topic by Mark Storey-Smith, Paul White, bluefeet, Michael - sqlbot, Max Vernon Jan 5 at 17:08

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Too localized - this could be because your code has a typo, basic error, or is not relevant to most of our audience. Consider revising your question so that it appeals to a broader audience. As it stands, the question is unlikely to help other users (regarding typo questions, see this meta question for background)." – Mark Storey-Smith, Paul White, bluefeet, Michael - sqlbot, Max Vernon
If this question can be reworded to fit the rules in the help center, please edit the question.

4  
I think you're confused - INFORMATION_SCHEMA is a schema containing many tables. It isn't a table –  Phil Jan 4 at 7:32
1  
And it is a "system" schema, you can't/shouldn't change its name. –  ypercube Jan 4 at 10:14
1  
Did you have a particular reason why changing this seems like something you should try to do? –  Michael - sqlbot Jan 4 at 22:58
    
Your latest edit (how to avoid SQL injection?) is a whole new question. Ask it seperately to get a better answer. Short answer: use prepared statements and parameterized queries. –  Iain Elder Jan 6 at 3:54
    
If you phrased your question with something like "is it worth shielding the mysql server from hackers by altering the information_schema and mysql schema names and how to do so?", I might vote to reopen. The short answer would still be "No, it's not and you can't easily do that" though. –  ypercube Jan 6 at 9:04

2 Answers 2

I wouldn't say this is impossible (MySQL is open source so hacking the source code could bring about this change) but I wouldn't advise it. Information_schema is an ANSI standard and isn't limited to MySQL. It contains virtual tables or views describing metadata about the server.

More detail here. http://en.wikipedia.org/wiki/Information_schema

Hopefully this will enlighten you to why it's there and why it's managed by the server not the user.

share|improve this answer

Unless you have the source code and recompile it, it is totally impossible to do so. Why ???

The INFORMATION_SCHEMA database contains the metadata about every database, every table, and every column, every index, every constraint defined that your current user can access in the MySQL instance.

Here is my post from Jun 15 2011 on how it is implemented : How is INFORMATION_SCHEMA implemented in MySQL?

As an example from that post, here is INFORMATION_SCHEMA.TABLES

mysql> show create table information_schema.tables\G
*************************** 1. row ***************************
       Table: TABLES
Create Table: CREATE TEMPORARY TABLE `TABLES` (
  `TABLE_CATALOG` varchar(512) NOT NULL DEFAULT '',
  `TABLE_SCHEMA` varchar(64) NOT NULL DEFAULT '',
  `TABLE_NAME` varchar(64) NOT NULL DEFAULT '',
  `TABLE_TYPE` varchar(64) NOT NULL DEFAULT '',
  `ENGINE` varchar(64) DEFAULT NULL,
  `VERSION` bigint(21) unsigned DEFAULT NULL,
  `ROW_FORMAT` varchar(10) DEFAULT NULL,
  `TABLE_ROWS` bigint(21) unsigned DEFAULT NULL,
  `AVG_ROW_LENGTH` bigint(21) unsigned DEFAULT NULL,
  `DATA_LENGTH` bigint(21) unsigned DEFAULT NULL,
  `MAX_DATA_LENGTH` bigint(21) unsigned DEFAULT NULL,
  `INDEX_LENGTH` bigint(21) unsigned DEFAULT NULL,
  `DATA_FREE` bigint(21) unsigned DEFAULT NULL,
  `AUTO_INCREMENT` bigint(21) unsigned DEFAULT NULL,
  `CREATE_TIME` datetime DEFAULT NULL,
  `UPDATE_TIME` datetime DEFAULT NULL,
  `CHECK_TIME` datetime DEFAULT NULL,
  `TABLE_COLLATION` varchar(32) DEFAULT NULL,
  `CHECKSUM` bigint(21) unsigned DEFAULT NULL,
  `CREATE_OPTIONS` varchar(255) DEFAULT NULL,
  `TABLE_COMMENT` varchar(2048) NOT NULL DEFAULT ''
) ENGINE=MEMORY DEFAULT CHARSET=utf8
1 row in set (0.00 sec)

Please note that this is a temporary table. All databases you create in a MySQL instance have a subfolder under datadir. The only exception is INFORMATION_SCHEMA. All the tables exist in memory. mysql will not let you change it no matter what you do.

I can understand you wanting to rename it. Whenever you run SHOW DATABASES;, INFORMATION_SCHEMA always appears first before all the other databases. You will have to run queries and filter INFORMATION_SCHEMA out of the results. This would seem annoying, but the effort to go into the source code and alter this behavior is simply not worth it.

CAVEAT : Click here to see all my posts on how to utilize the INFORMATION_SCHEMA database to address a variety of MySQL problems.

share|improve this answer

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