Database Server Installation Shared » History » Version 4
Amber Herold, 04/20/2010 12:24 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 | 4 | Amber Herold | 1. Copy my-huge.cnf to my.cnf |
48 | <pre> |
||
49 | > cp /usr/share/mysql/my-huge.cnf /etc/my.cnf |
||
50 | </pre> |
||
51 | 1 | Amber Herold | |
52 | 2. Edit /etc/my.cnf to add or change query cache variables like these: |
||
53 | query_cache_type= 1 |
||
54 | query_cache_size = 100M |
||
55 | query_cache_limit= 100M |
||
56 | |||
57 | h3. 5. start MySQL Server |
||
58 | |||
59 | 3 | Amber Herold | <pre> |
60 | 1 | Amber Herold | >/etc/init.d/mysqld start |
61 | 3 | Amber Herold | </pre> |
62 | 1 | Amber Herold | |
63 | on some installation, |
||
64 | |||
65 | 3 | Amber Herold | <pre> |
66 | 1 | Amber Herold | >/etc/init.d/mysql start |
67 | 3 | Amber Herold | </pre> |
68 | 1 | Amber Herold | |
69 | For future reference: start | stop | restart MySQL Server with similar commands: |
||
70 | |||
71 | 3 | Amber Herold | <pre> |
72 | 1 | Amber Herold | >/etc/init.d/mysqld start |
73 | >/etc/init.d/mysqld stop |
||
74 | >/etc/init.d/mysqld restart |
||
75 | 3 | Amber Herold | </pre> |
76 | 1 | Amber Herold | |
77 | If you want to start MySQL automatically at boot on SuSE |
||
78 | |||
79 | 3 | Amber Herold | <pre> |
80 | 1 | Amber Herold | SuSE >chkconfig mysql on |
81 | 3 | Amber Herold | </pre> |
82 | 1 | Amber Herold | |
83 | h3. 6. For future reference, the database location will be: |
||
84 | |||
85 | 3 | Amber Herold | <pre> |
86 | 1 | Amber Herold | > cd /var/lib/mysql |
87 | Directory: /var/lib/mysql |
||
88 | > ls |
||
89 | yourdbserver.pid |
||
90 | ib_logfile0 |
||
91 | mysql |
||
92 | mysql.sock |
||
93 | test |
||
94 | > |
||
95 | 3 | Amber Herold | </pre> |
96 | 1 | Amber Herold | |
97 | h3. 7. Create the Leginon database, call it leginondb |
||
98 | |||
99 | 3 | Amber Herold | <pre> |
100 | 1 | Amber Herold | >mysqladmin create leginondb |
101 | 3 | Amber Herold | </pre> |
102 | 1 | Amber Herold | |
103 | h3. 8. Create the Project database, call it projectdb |
||
104 | |||
105 | 3 | Amber Herold | <pre> |
106 | 1 | Amber Herold | >mysqladmin create projectdb |
107 | 3 | Amber Herold | </pre> |
108 | 1 | Amber Herold | |
109 | h3. 9. Connect to mysql db |
||
110 | |||
111 | <pre> |
||
112 | >mysql mysql |
||
113 | |||
114 | mysql> select user, password, host from user; |
||
115 | +------+----------+-----------+ |
||
116 | | user | password | host | |
||
117 | +------+----------+-----------+ |
||
118 | | root | | localhost | |
||
119 | | root | | host1 | |
||
120 | | | | host1 | |
||
121 | | | | localhost | |
||
122 | +------+----------+-----------+ |
||
123 | 4 rows in set (0.00 sec) |
||
124 | </pre> |
||
125 | |||
126 | h3. 10. Create user |
||
127 | |||
128 | 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 |
||
129 | |||
130 | 3 | Amber Herold | <pre> |
131 | 1 | Amber Herold | mysql> create user usr_object@'localhost'; |
132 | mysql> grant all privileges on leginondb.* to usr_object@'localhost'; |
||
133 | mysql> grant all privileges on projectdb.* to usr_object@'localhost'; |
||
134 | 3 | Amber Herold | </pre> |
135 | 1 | Amber Herold | |
136 | Similarly, |
||
137 | |||
138 | 3 | Amber Herold | <pre> |
139 | 1 | Amber Herold | mysql> create user usr_object@'%'; |
140 | mysql> grant all privileges on leginondb.* to usr_object@'%'; |
||
141 | mysql> grant all privileges on projectdb.* to usr_object@'%'; |
||
142 | 3 | Amber Herold | </pre> |
143 | 1 | Amber Herold | |
144 | Next, give create and access privileges for the processing databases which begin with "ap". |
||
145 | |||
146 | 3 | Amber Herold | <pre> |
147 | 1 | Amber Herold | // if your web host is local |
148 | mysql> grant all privileges on `ap%`.* to usr_object@localhost; |
||
149 | // for all other hosts if you are accessing the databases from another computer |
||
150 | mysql> grant all privileges on `ap%`.* to usr_object@`%`; |
||
151 | 3 | Amber Herold | </pre> |
152 | 1 | Amber Herold | |
153 | h3. 11. Change Root password |
||
154 | |||
155 | <pre> |
||
156 | mysql> update user set password=password('your_own_root_password') where user="root"; |
||
157 | Query OK, 2 rows affected (0.01 sec) |
||
158 | Rows matched: 2 Changed: 2 Warnings: 0 |
||
159 | |||
160 | mysql> flush privileges; |
||
161 | mysql>^D or exit; |
||
162 | </pre> |
||
163 | |||
164 | From now on, you will need to specify the password to connect to the database as root user like this: |
||
165 | |||
166 | 3 | Amber Herold | <pre> |
167 | 1 | Amber Herold | >mysql -u root -p mysql |
168 | 3 | Amber Herold | </pre> |
169 | 1 | Amber Herold | |
170 | h3. 12. Check MySQL variables |
||
171 | |||
172 | <pre> |
||
173 | >mysql -u usr_object leginondb |
||
174 | |||
175 | mysql> SHOW VARIABLES LIKE 'query%'; |
||
176 | +------------------------------+-----------+ |
||
177 | | Variable_name | Value | |
||
178 | +------------------------------+-----------+ |
||
179 | | ft_query_expansion_limit | 20 | |
||
180 | | have_query_cache | YES | |
||
181 | | long_query_time | 10 | |
||
182 | | query_alloc_block_size | 8192 | |
||
183 | | query_cache_limit | 104857600 | <<---This should correspond to your change |
||
184 | | query_cache_min_res_unit | 4096 | |
||
185 | | query_cache_size | 104857600 | <<---This should correspond to your change |
||
186 | | query_cache_type | ON | <<---This should correspond to your change |
||
187 | | query_cache_wlock_invalidate | OFF | |
||
188 | | query_prealloc_size | 8192 | |
||
189 | +------------------------------+-----------+ |
||
190 | 10 rows in set (0.00 sec) |
||
191 | |||
192 | mysql> exit; |
||
193 | </pre> |
||
194 | |||
195 | h3. 13. Make sure MySQL is running |
||
196 | |||
197 | <pre> |
||
198 | prompt:~> mysqlshow |
||
199 | +--------------+ |
||
200 | | Databases | |
||
201 | +--------------+ |
||
202 | | mysql | |
||
203 | | leginondb | |
||
204 | | projectdb | |
||
205 | +--------------+ |
||
206 | </pre> |
||
207 | |||
208 | h3. 14. Or check with the following php script (if already installed) |
||
209 | |||
210 | 3 | Amber Herold | <pre> |
211 | 1 | Amber Herold | <? |
212 | mysql_connect('your_host.your_institute.edu', 'usr_object', '','leginondb'); |
||
213 | echo mysql_stat(); |
||
214 | ?> |
||
215 | 3 | Amber Herold | </pre> |
216 | 1 | Amber Herold | |
217 | 3 | Amber Herold | Output: |
218 | 1 | Amber Herold | |
219 | 3 | Amber Herold | <pre> |
220 | 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 |
221 | 3 | Amber Herold | </pre> |
222 | 1 | Amber Herold | |
223 | h2. Configure phpMyAdmin |
||
224 | |||
225 | Edit the phpMyAdmin config file: |
||
226 | |||
227 | <pre> |
||
228 | $ sudo vi /etc/phpMyAdmin/config.inc.php |
||
229 | </pre> |
||
230 | |||
231 | and change the following lines: |
||
232 | |||
233 | <pre> |
||
234 | $cfg['Servers'][$i]['AllowRoot'] = FALSE; |
||
235 | </pre> |
||
236 | |||
237 | Edit the phpMyAdmin apache config file: |
||
238 | |||
239 | <pre> |
||
240 | $ sudo vi /etc/httpd/conf.d/phpMyAdmin.conf |
||
241 | </pre> |
||
242 | |||
243 | and change the following lines: |
||
244 | |||
245 | *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 |
||
246 | |||
247 | <pre> |
||
248 | <Directory /usr/share/phpMyAdmin/> |
||
249 | order deny,allow |
||
250 | deny from all |
||
251 | allow from 127.0.0.1 |
||
252 | allow from YOUR_IP_ADDRESS |
||
253 | </Directory> |
||
254 | </pre> |
||
255 | |||
256 | To test the PHPMyAdmin configuration, point your browser to http://YOUR_IP_ADDRESS/phpmyadmin. |