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