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