mysql_system_tables_data.sql 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. -- Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
  2. --
  3. -- This program is free software; you can redistribute it and/or modify
  4. -- it under the terms of the GNU General Public License as published by
  5. -- the Free Software Foundation; version 2 of the License.
  6. --
  7. -- This program is distributed in the hope that it will be useful,
  8. -- but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. -- GNU General Public License for more details.
  11. --
  12. -- You should have received a copy of the GNU General Public License
  13. -- along with this program; if not, write to the Free Software
  14. -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  15. --
  16. -- The inital data for system tables of MySQL Server
  17. --
  18. -- When setting up a "cross bootstrap" database (e.g., creating data on a Unix
  19. -- host which will later be included in a Windows zip file), any lines
  20. -- containing "@current_hostname" are filtered out by mysql_install_db.
  21. -- Get the hostname, if the hostname has any wildcard character like "_" or "%"
  22. -- add escape character in front of wildcard character to convert "_" or "%" to
  23. -- a plain character
  24. SELECT LOWER( REPLACE((SELECT REPLACE(@@hostname,'_','\_')),'%','\%') )INTO @current_hostname;
  25. -- Fill "db" table with default grants for anyone to
  26. -- access database 'test' and 'test_%' if "db" table didn't exist
  27. CREATE TEMPORARY TABLE tmp_db LIKE db;
  28. INSERT INTO tmp_db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y');
  29. INSERT INTO tmp_db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y');
  30. INSERT INTO db SELECT * FROM tmp_db WHERE @had_db_table=0;
  31. DROP TABLE tmp_db;
  32. -- Fill "user" table with default users allowing root access
  33. -- from local machine if "user" table didn't exist before
  34. CREATE TEMPORARY TABLE tmp_user LIKE user;
  35. INSERT INTO tmp_user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'','','N');
  36. REPLACE INTO tmp_user SELECT @current_hostname,'root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'','','N' FROM dual WHERE @current_hostname != 'localhost';
  37. REPLACE INTO tmp_user VALUES ('127.0.0.1','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'','','N');
  38. REPLACE INTO tmp_user VALUES ('::1','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'','','N');
  39. INSERT INTO tmp_user (host,user) VALUES ('localhost','');
  40. INSERT INTO tmp_user (host,user) SELECT @current_hostname,'' FROM dual WHERE @current_hostname != 'localhost';
  41. INSERT INTO user SELECT * FROM tmp_user WHERE @had_user_table=0;
  42. DROP TABLE tmp_user;
  43. CREATE TEMPORARY TABLE tmp_proxies_priv LIKE proxies_priv;
  44. INSERT INTO tmp_proxies_priv VALUES ('localhost', 'root', '', '', TRUE, '', now());
  45. REPLACE INTO tmp_proxies_priv SELECT @current_hostname, 'root', '', '', TRUE, '', now() FROM DUAL WHERE LOWER (@current_hostname) != 'localhost';
  46. INSERT INTO proxies_priv SELECT * FROM tmp_proxies_priv WHERE @had_proxies_priv_table=0;
  47. DROP TABLE tmp_proxies_priv;