Project

General

Profile

Setup Local Databases » History » Version 7

Amber Herold, 12/20/2010 12:13 PM

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 7 Amber Herold
<pre>
32
mysqldump -h cronus4 -u amber -p --skip-lock-tables --extended-insert project > Project.sql
33
</pre>
34
35 3 Neil Voss
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
36 1 Amber Herold
37 2 Amber Herold
More info on mysqldump is "here":http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_tables.
38
39 1 Amber Herold
Exit cronus3 when you are done dumping tables and load the dump files into your database.
40
If you followed the instructions for setting up MySQL in the Leginon Install guide, you have already created dbemdata and projectdata databases.
41
If you don't have them, create them first.
42
43
<pre>
44
mysql -u root projectdata < ProjectLogin.sql
45
</pre>
46
47
h2. 3 Modify Config.php
48
49 6 Amber Herold
This is the Myami config file. It is being changed right now so this is in flux. Will update soon.
50
51 1 Amber Herold
It should look like this:
52
53
<pre>
54
// --- Set your leginon MySQL database server parameters
55
56
$DB_HOST        = "localhost";
57
$DB_USER        = "usr_object";
58
$DB_PASS        = "";
59
$DB             = "dbemdata";
60
61
// --- XML test dataset
62
$XML_DATA = "test/viewerdata.xml";
63
64
// --- Project database URL
65
66
$PROJECT_URL = "project";
67
$PROJECT_DB_HOST = "localhost";
68
$PROJECT_DB_USER = "usr_object";
69
$PROJECT_DB_PASS = "";
70
$PROJECT_DB = "projectdata";
71
</pre>
72
73
h2. 4 Populate your databases automagically
74
75
Point your web browser to http://localhost/myamiweb/.
76
Navigate to the Administration page and then to the ProjectDB page. 
77
78
Doing this will populate your database with the schema defined in myami/myamiweb/project/defaultprojecttables.xml.
79 5 Amber Herold
If you need to repopulate tables, use phpMyadmin to empty the Install table in the project DB. Then repeat the steps above.