grass-mysql.html 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>GRASS GIS manual: GRASS-MySQL driver</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <link rel="stylesheet" href="grassdocs.css" type="text/css">
  7. </head>
  8. <body bgcolor="white">
  9. <img src="grass_logo.png" alt="GRASS logo"><hr align=center size=6 noshade>
  10. <!-- meta page description: MySQL driver -->
  11. <h1>MySQL driver in GRASS</h1>
  12. <h2>KEYWORDS</h2>
  13. database, attribute table, driver
  14. <h2>DESCRIPTION</h2>
  15. MySQL database driver in GRASS enables GRASS to store vector
  16. attributes in MySQL server.
  17. <p>
  18. Because vector attribute tables
  19. are created automatically when a new vector is written and the
  20. name of the table is the same as the name of the vector it is
  21. good practice to create a new database for each GRASS mapset.
  22. <h2>Creating a MySQL database</h2>
  23. A new database is created within MySQL:
  24. <div class="code"><pre>
  25. mysql> CREATE DATABASE mydb;
  26. </pre></div>
  27. See the MySQL manual for details.
  28. <h2>Driver and database name</h2>
  29. GRASS modules require 2 parameters to connect to a database.
  30. Those parameters are 'driver' and 'database'. For MySQL driver
  31. the parameter 'driver' should be set to value 'mysql'.
  32. The parameter 'database' can be given in two formats:
  33. <ul>
  34. <li> Database name - in case of connection from localhost
  35. <li> String of comma separated list of kye=value options.
  36. Supported options are:
  37. <ul>
  38. <li> dbname - database name
  39. <li> host - host name or IP address
  40. <li> port - server port number
  41. </ul>
  42. </ul>
  43. Examples of connection parameters:
  44. <pre>
  45. db.connect driver=mysql database=mytest
  46. db.connect driver=mysql database='dbname=mytest,host=test.grass.org'
  47. </pre>
  48. <h2>Data types</h2>
  49. GRASS supports almost all MySQL data types with following limitations:
  50. <ul>
  51. <li> Binary columns (BINARY, VARBINARY, TINYBLOB, MEDIUMBLOB,
  52. BLOB, LONGBLOB) are not not supported.
  53. If a table with binary column(s) is used in GRASS
  54. a warning is printed and only the supported columns are
  55. returned in query results.
  56. <li> Columns of type SET and ENUM are represented as string (VARCHAR).
  57. <li> Very large integers in columns of type BIGINT can be lost
  58. or corrupted because GRASS does not support 64 bin integeres
  59. on most platforms.
  60. <li> GRASS does not currently distinguish types TIMESTAMP and
  61. DATETIME. Both types are in GRASS interpreted as TIMESTAMP.
  62. </ul>
  63. <h2>Indexes</h2>
  64. GRASS modules automatically create index on key column of vector
  65. attributes table. The index on key column is important
  66. for performance of modules which update the attribute table,
  67. for example v.to.db, v.distance and v.what.rast.
  68. <h2>Privileges</h2>
  69. Because MySQL does not support groups of users and because
  70. only MySQL 'root' can grant privileges to other users
  71. GRASS cannot automatically grant select privileges on created
  72. tables to group of users.
  73. <p>
  74. If you want to give privilege to read data from your mapset
  75. to other users you have to ask your MySQL server administrator
  76. to grant select privilege to them on the MySQL database used
  77. for that mapset. For example, to allow everybody to read data
  78. in from your database 'mydb':<br>
  79. <pre>
  80. shell&gt; mysql --user=root mysql
  81. mysql&gt; GRANT SELECT ON mydb.* TO ''@'%';
  82. </pre>
  83. <h2>Schemas</h2>
  84. Because MySQL does not support database schemas the parameter
  85. 'schema' of module db.connect should never be set to any
  86. value. If you set that parameter for MySQL driver GRASS will
  87. try to write tables to the specified schema which will result
  88. in errors.
  89. <h2>Groups</h2>
  90. MySQL does not support user groups. Any settings specified
  91. by 'group' parameter of module db.connect are ignored by
  92. GRASS for MySQL driver.
  93. <h2>Troubleshooting: SQL syntax error</h2>
  94. Attempting to use a reserved SQL word as column or table name will result
  95. in a "SQL syntax" error. The list of reserved words for MySQL can be
  96. found in the <a href="http://dev.mysql.com/doc/refman/5.7/en/reserved-words.html#table-reserved-words-5.7.4">MySQL manual</a>.
  97. <h2>SEE ALSO</h2>
  98. <em>
  99. <a href="db.connect.html">db.connect</a>,
  100. <a href="sql.html">SQL support in GRASS GIS</a>
  101. </em>
  102. <h2>Credits</h2>
  103. Development of the driver was sponsored by
  104. <a href="http://www.faunalia.it">Faunalia</a> (Italy)
  105. as part of a project for <a href="http://www.atac.roma.it/">ATAC</a>.
  106. <h2>AUTHOR</h2>
  107. Radim Blazek
  108. <p>
  109. <i>Last changed: $Date$</i>
  110. <hr class="header">
  111. <p><a href="index.html">Main index</a> - <a href="database.html">Database index</a> - <a href="topics.html">Topics index</a> - <a href="keywords.html">Keywords Index</a> - <a href="full_index.html">Full index</a></p>
  112. <p>&copy; 2003-2013 <a href="http://grass.osgeo.org">GRASS Development Team</a>, GRASS GIS 7.0.svn Reference Manual</p>
  113. </body>
  114. </html>