Project

General

Profile

Setup Local Databases » History » Version 4

Amber Herold, 02/11/2010 09:11 AM

1 1 Amber Herold
h1. Setup Local Databases 
2
3
{{>toc}}
4
5
h2. 1 Make sure MySQL is installed
6
7
Follow the instructions in the "Leginon install guide":http://emg.nysbc.org/documentation/leginon/bk02ch04s07.php.
8
 
9
Also install phpMyAdmin found under "Other Tools" on "this page":http://emg.nysbc.org/documentation/leginon/bk02ch04s08.php.
10
Note that phpMyAdmin version 2.11.10 works with older versions of PHP (that we happen to use).
11
12
h2. 2 Dump tables from cronus4 to a local file
13
14
This will grab the actual data that we use so you can play with it.
15
Log into cronus3 so that you can access cronus4.
16
17
<pre>
18
$ ssh cronus3
19
</pre>
20
21
Use mysqldump to get any table data that you want as in the example below. 
22
Cronus4 is the host. 
23
We do not lock the tables because we don't have permission to. 
24
"project" is the name of the database and "login" is the name of the Table.
25
We make up a file name for the data to dump to.
26
27
<pre>
28 3 Neil Voss
$ mysqldump -h cronus4 -u usr_object --skip-lock-tables --extended-insert project login > ProjectLogin.sql
29 1 Amber Herold
</pre>
30 3 Neil Voss
31
The @--extended-insert@ option causes mysqldump to generate multi-value INSERT commands inside the backup text file which results in the file being smaller and the restore running faster. "ref":http://www.mythtv.org/wiki/Backup_your_database
32 1 Amber Herold
33 2 Amber Herold
More info on mysqldump is "here":http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_tables.
34
35 1 Amber Herold
Exit cronus3 when you are done dumping tables and load the dump files into your database.
36
If you followed the instructions for setting up MySQL in the Leginon Install guide, you have already created dbemdata and projectdata databases.
37
If you don't have them, create them first.
38
39
<pre>
40
mysql -u root projectdata < ProjectLogin.sql
41
</pre>
42
43
h2. 3 Modify Config.php
44
45
It should look like this:
46
47
<pre>
48
// --- Set your leginon MySQL database server parameters
49
50
$DB_HOST        = "localhost";
51
$DB_USER        = "usr_object";
52
$DB_PASS        = "";
53
$DB             = "dbemdata";
54
55
// --- XML test dataset
56
$XML_DATA = "test/viewerdata.xml";
57
58
// --- Project database URL
59
60
$PROJECT_URL = "project";
61
$PROJECT_DB_HOST = "localhost";
62
$PROJECT_DB_USER = "usr_object";
63
$PROJECT_DB_PASS = "";
64
$PROJECT_DB = "projectdata";
65
</pre>
66
67
h2. 4 Populate your databases automagically
68
69
Point your web browser to http://localhost/myamiweb/.
70
Navigate to the Administration page and then to the ProjectDB page. 
71
72
Doing this will populate your database with the schema defined in myami/myamiweb/project/defaultprojecttables.xml.
73 4 Amber Herold
74
If you need to repopulate tables, use phpMyadmin to empty the Install table in the project DB.