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