Database Server Installation Shared » History » Version 5
Amber Herold, 04/20/2010 12:26 PM
1 | 1 | Amber Herold | h1. Database Server Installation |
---|---|---|---|
2 | |||
3 | |||
4 | h2. Install MySQL |
||
5 | |||
6 | The following is for the computer that hosts the databases. This involves installing MySQL server and creation/configuration of the leginondb and projectdb databases. |
||
7 | |||
8 | Note: You may already have MySQL Server and Client installed. Check by typing mysql at the command line. |
||
9 | If you see a MySQL prompt (mysql>), skip steps 1 and 2. |
||
10 | |||
11 | h3. 1. Install MySQL-Server |
||
12 | |||
13 | * Use your package installer (yum, zypper, YaST) if available. |
||
14 | OR |
||
15 | * Download the latest MySQL-server RPM for Linux from www.mysql.com |
||
16 | * Install the MySQL-server rpm: |
||
17 | |||
18 | rpm -Uvh MySQL-server-5.0.xx-y.i386.rpm |
||
19 | |||
20 | (substitute correct version numbers) |
||
21 | |||
22 | h3. 2. Install MySQL-Client |
||
23 | |||
24 | * Use your package installer (yum, zypper, YaST) if available. |
||
25 | OR |
||
26 | * Download the latest MySQL-client RPM for Linux from www.mysql.com |
||
27 | * Install the MySQL-client rpm: |
||
28 | |||
29 | rpm -Uvh MySQL-client-5.0.xx-y.i386.rpm |
||
30 | |||
31 | (substitute correct version numbers) |
||
32 | |||
33 | h3. 3. MySQL configuration file is usually located in /usr/share/mysql. There are several examples there: |
||
34 | |||
35 | 3 | Amber Herold | <pre> |
36 | 1 | Amber Herold | > ls /usr/share/mysql/my* |
37 | /usr/share/mysql/my-huge.cnf |
||
38 | /usr/share/mysql/my-innodb-heavy-4G.cnf |
||
39 | /usr/share/mysql/my-large.cnf |
||
40 | /usr/share/mysql/my-medium.cnf |
||
41 | /usr/share/mysql/my-small.cnf |
||
42 | > |
||
43 | 3 | Amber Herold | </pre> |
44 | 1 | Amber Herold | |
45 | h3. 4. Configure my.cnf in /etc using my-huge.cnf as the template |
||
46 | |||
47 | 5 | Amber Herold | # Copy my-huge.cnf to my.cnf |
48 | 4 | Amber Herold | <pre> |
49 | > cp /usr/share/mysql/my-huge.cnf /etc/my.cnf |
||
50 | 1 | Amber Herold | </pre> |
51 | 5 | Amber Herold | # Edit /etc/my.cnf to add or change query cache variables like these: |
52 | 1 | Amber Herold | query_cache_type= 1 |
53 | query_cache_size = 100M |
||
54 | query_cache_limit= 100M |
||
55 | |||
56 | h3. 5. start MySQL Server |
||
57 | |||
58 | 3 | Amber Herold | <pre> |
59 | 1 | Amber Herold | >/etc/init.d/mysqld start |
60 | 3 | Amber Herold | </pre> |
61 | 1 | Amber Herold | |
62 | on some installation, |
||
63 | |||
64 | 3 | Amber Herold | <pre> |
65 | 1 | Amber Herold | >/etc/init.d/mysql start |
66 | 3 | Amber Herold | </pre> |
67 | 1 | Amber Herold | |
68 | For future reference: start | stop | restart MySQL Server with similar commands: |
||
69 | |||
70 | 3 | Amber Herold | <pre> |
71 | 1 | Amber Herold | >/etc/init.d/mysqld start |
72 | >/etc/init.d/mysqld stop |
||
73 | >/etc/init.d/mysqld restart |
||
74 | 3 | Amber Herold | </pre> |
75 | 1 | Amber Herold | |
76 | If you want to start MySQL automatically at boot on SuSE |
||
77 | |||
78 | 3 | Amber Herold | <pre> |
79 | 1 | Amber Herold | SuSE >chkconfig mysql on |
80 | 3 | Amber Herold | </pre> |
81 | 1 | Amber Herold | |
82 | h3. 6. For future reference, the database location will be: |
||
83 | |||
84 | 3 | Amber Herold | <pre> |
85 | 1 | Amber Herold | > cd /var/lib/mysql |
86 | Directory: /var/lib/mysql |
||
87 | > ls |
||
88 | yourdbserver.pid |
||
89 | ib_logfile0 |
||
90 | mysql |
||
91 | mysql.sock |
||
92 | test |
||
93 | > |
||
94 | 3 | Amber Herold | </pre> |
95 | 1 | Amber Herold | |
96 | h3. 7. Create the Leginon database, call it leginondb |
||
97 | |||
98 | 3 | Amber Herold | <pre> |
99 | 1 | Amber Herold | >mysqladmin create leginondb |
100 | 3 | Amber Herold | </pre> |
101 | 1 | Amber Herold | |
102 | h3. 8. Create the Project database, call it projectdb |
||
103 | |||
104 | 3 | Amber Herold | <pre> |
105 | 1 | Amber Herold | >mysqladmin create projectdb |
106 | 3 | Amber Herold | </pre> |
107 | 1 | Amber Herold | |
108 | h3. 9. Connect to mysql db |
||
109 | |||
110 | <pre> |
||
111 | >mysql mysql |
||
112 | |||
113 | mysql> select user, password, host from user; |
||
114 | +------+----------+-----------+ |
||
115 | | user | password | host | |
||
116 | +------+----------+-----------+ |
||
117 | | root | | localhost | |
||
118 | | root | | host1 | |
||
119 | | | | host1 | |
||
120 | | | | localhost | |
||
121 | +------+----------+-----------+ |
||
122 | 4 rows in set (0.00 sec) |
||
123 | </pre> |
||
124 | |||
125 | h3. 10. Create user |
||
126 | |||
127 | Create and grant privileges to a user called usr_object for the databases on both the localhost and other hosts involved. For example, use wild card '%' for all hosts. You may also set specific privilege to the user. See MySQL Reference Manual for details |
||
128 | |||
129 | 3 | Amber Herold | <pre> |
130 | 1 | Amber Herold | mysql> create user usr_object@'localhost'; |
131 | mysql> grant all privileges on leginondb.* to usr_object@'localhost'; |
||
132 | mysql> grant all privileges on projectdb.* to usr_object@'localhost'; |
||
133 | 3 | Amber Herold | </pre> |
134 | 1 | Amber Herold | |
135 | Similarly, |
||
136 | |||
137 | 3 | Amber Herold | <pre> |
138 | 1 | Amber Herold | mysql> create user usr_object@'%'; |
139 | mysql> grant all privileges on leginondb.* to usr_object@'%'; |
||
140 | mysql> grant all privileges on projectdb.* to usr_object@'%'; |
||
141 | 3 | Amber Herold | </pre> |
142 | 1 | Amber Herold | |
143 | Next, give create and access privileges for the processing databases which begin with "ap". |
||
144 | |||
145 | 3 | Amber Herold | <pre> |
146 | 1 | Amber Herold | // if your web host is local |
147 | mysql> grant all privileges on `ap%`.* to usr_object@localhost; |
||
148 | // for all other hosts if you are accessing the databases from another computer |
||
149 | mysql> grant all privileges on `ap%`.* to usr_object@`%`; |
||
150 | 3 | Amber Herold | </pre> |
151 | 1 | Amber Herold | |
152 | h3. 11. Change Root password |
||
153 | |||
154 | <pre> |
||
155 | mysql> update user set password=password('your_own_root_password') where user="root"; |
||
156 | Query OK, 2 rows affected (0.01 sec) |
||
157 | Rows matched: 2 Changed: 2 Warnings: 0 |
||
158 | |||
159 | mysql> flush privileges; |
||
160 | mysql>^D or exit; |
||
161 | </pre> |
||
162 | |||
163 | From now on, you will need to specify the password to connect to the database as root user like this: |
||
164 | |||
165 | 3 | Amber Herold | <pre> |
166 | 1 | Amber Herold | >mysql -u root -p mysql |
167 | 3 | Amber Herold | </pre> |
168 | 1 | Amber Herold | |
169 | h3. 12. Check MySQL variables |
||
170 | |||
171 | <pre> |
||
172 | >mysql -u usr_object leginondb |
||
173 | |||
174 | mysql> SHOW VARIABLES LIKE 'query%'; |
||
175 | +------------------------------+-----------+ |
||
176 | | Variable_name | Value | |
||
177 | +------------------------------+-----------+ |
||
178 | | ft_query_expansion_limit | 20 | |
||
179 | | have_query_cache | YES | |
||
180 | | long_query_time | 10 | |
||
181 | | query_alloc_block_size | 8192 | |
||
182 | | query_cache_limit | 104857600 | <<---This should correspond to your change |
||
183 | | query_cache_min_res_unit | 4096 | |
||
184 | | query_cache_size | 104857600 | <<---This should correspond to your change |
||
185 | | query_cache_type | ON | <<---This should correspond to your change |
||
186 | | query_cache_wlock_invalidate | OFF | |
||
187 | | query_prealloc_size | 8192 | |
||
188 | +------------------------------+-----------+ |
||
189 | 10 rows in set (0.00 sec) |
||
190 | |||
191 | mysql> exit; |
||
192 | </pre> |
||
193 | |||
194 | h3. 13. Make sure MySQL is running |
||
195 | |||
196 | <pre> |
||
197 | prompt:~> mysqlshow |
||
198 | +--------------+ |
||
199 | | Databases | |
||
200 | +--------------+ |
||
201 | | mysql | |
||
202 | | leginondb | |
||
203 | | projectdb | |
||
204 | +--------------+ |
||
205 | </pre> |
||
206 | |||
207 | h3. 14. Or check with the following php script (if already installed) |
||
208 | |||
209 | 3 | Amber Herold | <pre> |
210 | 1 | Amber Herold | <? |
211 | mysql_connect('your_host.your_institute.edu', 'usr_object', '','leginondb'); |
||
212 | echo mysql_stat(); |
||
213 | ?> |
||
214 | 3 | Amber Herold | </pre> |
215 | 1 | Amber Herold | |
216 | 3 | Amber Herold | Output: |
217 | 1 | Amber Herold | |
218 | 3 | Amber Herold | <pre> |
219 | 1 | Amber Herold | Uptime: 1452562 Threads: 1 Questions: 618 Slow queries: 0 Opens: 117 Flush tables: 1 Open tables: 106 Queries per second avg: 0.000 |
220 | 3 | Amber Herold | </pre> |
221 | 1 | Amber Herold | |
222 | h2. Configure phpMyAdmin |
||
223 | |||
224 | Edit the phpMyAdmin config file: |
||
225 | |||
226 | <pre> |
||
227 | $ sudo vi /etc/phpMyAdmin/config.inc.php |
||
228 | </pre> |
||
229 | |||
230 | and change the following lines: |
||
231 | |||
232 | <pre> |
||
233 | $cfg['Servers'][$i]['AllowRoot'] = FALSE; |
||
234 | </pre> |
||
235 | |||
236 | Edit the phpMyAdmin apache config file: |
||
237 | |||
238 | <pre> |
||
239 | $ sudo vi /etc/httpd/conf.d/phpMyAdmin.conf |
||
240 | </pre> |
||
241 | |||
242 | and change the following lines: |
||
243 | |||
244 | *Note:* If you want to access phpMyAdmin from another computer, you can add it to its web access configuration file found as /etc/httpd/conf.d/phpMyAdmin.conf in a typical installation |
||
245 | |||
246 | <pre> |
||
247 | <Directory /usr/share/phpMyAdmin/> |
||
248 | order deny,allow |
||
249 | deny from all |
||
250 | allow from 127.0.0.1 |
||
251 | allow from YOUR_IP_ADDRESS |
||
252 | </Directory> |
||
253 | </pre> |
||
254 | |||
255 | To test the PHPMyAdmin configuration, point your browser to http://YOUR_IP_ADDRESS/phpmyadmin. |