]> git.openstreetmap.org Git - rails.git/blob - db/README
Use validates_email_format_of as a gem instead of a plugin
[rails.git] / db / README
1 Creating database
2 ===================
3
4 OSM server uses a database with the following name:
5
6 openstreetmap
7
8 You may create it with your preferable client or run next (linux) command:
9
10 $ mysql -u <uid> -p
11
12 (change <uid> with appropriate username of administrative user eg. root )
13
14 > create database openstreetmap default character set utf8;
15 > exit
16
17 Creating user, password, and access rights
18 ============================================
19
20 $ mysql -u <uid> -p
21
22 (change <uid> with appropriate username of administrative user eg. root )
23
24 > grant all privileges on openstreetmap.* to 'openstreetmap'@'localhost' identified by 'openstreetmap';
25 > flush privileges;
26 > exit
27
28 Creating functions For MySQL
29 ==============================
30
31 Run this command in the db/functions directory:
32
33 $ make libmyosm.so
34
35 You might also need to install:
36 - mysql client development libraries:   $ sudo apt-get install libmysqlclient16-dev 
37 - ruby development libraries:           $ sudo apt-get install ruby1.8-dev
38 for build to succeed.
39
40 Make sure the db/functions directory is on the MySQL server's library
41 path and restart the MySQL server. 
42
43 On Linux the easiest way to do this is to create /etc/ld.so.conf.d/osm.conf, and place the path to the db/functions directory in it and then run the ldconfig command as root.
44
45 On OS X: sudo ln -s /path_to_your_osm_install/sites/rails_port/db/functions/libmyosm.so /usr/local/lib/libmyosm.so
46
47 Now create the functions as follows:
48
49 $ mysql -u <uid> -p openstreetmap
50
51 (change <uid> with appropriate username of administrative user eg. root )
52
53 > create function tile_for_point returns integer soname 'libmyosm.so';
54 > create function maptile_for_point returns integer soname 'libmyosm.so';
55 > exit
56
57 Creating functions for PgSQL
58 ==============================
59
60 Run this command in the db/functions directory:
61
62 $ make libpgosm.so
63
64 You might also need to install:
65 - postgresql development libraries:     $ sudo apt-get install postgresql-server-dev-8.3
66 - ruby development libraries:           $ sudo apt-get install ruby1.8-dev
67 for build to succeed.
68
69 Now create the function as follows:
70
71 $ psql openstreetmap
72 (This may need authentication or a -u <dbowneruid>)
73
74 > CREATE FUNCTION maptile_for_point(int8, int8, int4) RETURNS int4 
75   AS '/path/to/rails-port/db/functions/libpgosm.so', 'maptile_for_point'
76   LANGUAGE C STRICT;
77
78 Creating database skeleton tables
79 ===================================
80
81 Run this command from the root of your rails directory:
82
83 $ rake db:migrate
84
85 This will create the db for you
86
87 You will need to make sure the database connection is configured in database.yml in config directory
88 You might start with example configuration provided: 
89 $ cp config/mysql.example.database.yml config/database.yml