grass-mysql.html 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <!-- meta page description: MySQL DATABASE DRIVER -->
  2. MySQL database driver enables GRASS to store vector attributes in
  3. MySQL server.
  4. <p>
  5. Because vector attribute tables
  6. are created automatically when a new vector is written and the
  7. name of the table is the same as the name of the vector it is
  8. good practice to create a new database for each GRASS mapset.
  9. <h2>Creating a MySQL database</h2>
  10. A new database is created within MySQL:
  11. <div class="code"><pre>
  12. mysql> CREATE DATABASE mydb;
  13. </pre></div>
  14. See the MySQL manual for details.
  15. <h2>Driver and database name</h2>
  16. GRASS modules require 2 parameters to connect to a database.
  17. Those parameters are 'driver' and 'database'. For MySQL driver
  18. the parameter 'driver' should be set to value 'mysql'.
  19. The parameter 'database' can be given in two formats:
  20. <ul>
  21. <li> Database name - in case of connection from localhost
  22. <li> String of comma separated list of kye=value options.
  23. Supported options are:
  24. <ul>
  25. <li> dbname - database name
  26. <li> host - host name or IP address
  27. <li> port - server port number
  28. </ul>
  29. </ul>
  30. Examples of connection parameters:
  31. <pre>
  32. db.connect driver=mysql database=mytest
  33. db.connect driver=mysql database='dbname=mytest,host=test.grass.org'
  34. </pre>
  35. <h2>Data types</h2>
  36. GRASS supports almost all MySQL data types with following limitations:
  37. <ul>
  38. <li> Binary columns (BINARY, VARBINARY, TINYBLOB, MEDIUMBLOB,
  39. BLOB, LONGBLOB) are not not supported.
  40. If a table with binary column(s) is used in GRASS
  41. a warning is printed and only the supported columns are
  42. returned in query results.
  43. <li> Columns of type SET and ENUM are represented as string (VARCHAR).
  44. <li> Very large integers in columns of type BIGINT can be lost
  45. or corrupted because GRASS does not support 64 bin integeres
  46. on most platforms.
  47. <li> GRASS does not currently distinguish types TIMESTAMP and
  48. DATETIME. Both types are in GRASS interpreted as TIMESTAMP.
  49. </ul>
  50. <h2>Indexes</h2>
  51. GRASS modules automatically create index on key column of vector
  52. attributes table. The index on key column is important
  53. for performance of modules which update the attribute table,
  54. for example v.to.db, v.distance and v.what.rast.
  55. <h2>Privileges</h2>
  56. Because MySQL does not support groups of users and because
  57. only MySQL 'root' can grant privileges to other users
  58. GRASS cannot automatically grant select privileges on created
  59. tables to group of users.
  60. <p>
  61. If you want to give privilege to read data from your mapset
  62. to other users you have to ask your MySQL server administrator
  63. to grant select privilege to them on the MySQL database used
  64. for that mapset. For example, to allow everybody to read data
  65. in from your database 'mydb':<br>
  66. <pre>
  67. shell&gt; mysql --user=root mysql
  68. mysql&gt; GRANT SELECT ON mydb.* TO ''@'%';
  69. </pre>
  70. <h2>Schemas</h2>
  71. Because MySQL does not support database schemas the parameter
  72. 'schema' of module db.connect should never be set to any
  73. value. If you set that parameter for MySQL driver GRASS will
  74. try to write tables to the specified schema which will result
  75. in errors.
  76. <h2>Groups</h2>
  77. MySQL does not support user groups. Any settings specified
  78. by 'group' parameter of module db.connect are ignored by
  79. GRASS for MySQL driver.
  80. <h2>Troubleshooting: SQL syntax error</h2>
  81. Attempting to use a reserved SQL word as column or table name will result
  82. in a "SQL syntax" error. The list of reserved words for MySQL can be
  83. 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>.
  84. <h2>SEE ALSO</h2>
  85. <em>
  86. <a href="db.connect.html">db.connect</a>,
  87. <a href="sql.html">SQL support in GRASS GIS</a>
  88. </em>
  89. <h2>Credits</h2>
  90. Development of the driver was sponsored by
  91. <a href="http://www.faunalia.it">Faunalia</a> (Italy)
  92. as part of a project for <a href="http://www.atac.roma.it/">ATAC</a>.
  93. <h2>AUTHOR</h2>
  94. Radim Blazek