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