Project

General

Profile

Database Server Installation Shared » History » Version 2

Amber Herold, 04/16/2010 09:57 AM

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