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