Project

General

Profile

Database Server Setup to allow connection from the instruments » History » Version 15

Anchi Cheng, 04/11/2019 12:21 AM

1 9 Anchi Cheng
h1. Setup to allow connection from the instruments
2 1 Anchi Cheng
3 9 Anchi Cheng
h2. Allow remote access to database server (default in CentOS 6).
4 2 Anchi Cheng
5
h3. Edit /etc/my.cnf search for *skip-networking* and make sure it is commented out like this:
6
7
<pre>
8
#skip-networking
9 1 Anchi Cheng
</pre>
10 7 Anchi Cheng
11
Also look for bind-address in the same file and if it says 127.0.0.1, it will only listen to local connection.
12
You should comment that out as well.
13 3 Anchi Cheng
<pre>
14 7 Anchi Cheng
#bind-address=127.0.0.1
15 5 Anchi Cheng
</pre>
16 2 Anchi Cheng
17 7 Anchi Cheng
h3. Restart mysqld if you have made changes.
18 2 Anchi Cheng
19 15 Anchi Cheng
For CentOS7 that runs mariadb,
20 1 Anchi Cheng
<pre>
21 15 Anchi Cheng
sudo mysqladmin shutdown
22
sudo mysqld_safe
23
</pre>
24
25
For CentOS6, Fedora that runs mysql
26
<pre>
27 2 Anchi Cheng
sudo /etc/init.d/mysqld restart
28
</pre>
29
or
30
<pre>
31
sudo /sbin/service mysqld restart
32 1 Anchi Cheng
</pre>
33
34 8 Anchi Cheng
h2. Create remote user if autoinstaller was used
35 2 Anchi Cheng
36 9 Anchi Cheng
Autoinstaller creates only root user and only allow its access to database from the localhost.
37 1 Anchi Cheng
38 8 Anchi Cheng
The following assumes that you want to use usr_object user for remote access as referenced in most of this document.
39
40
h3. Create and grant privileges to the usr_object for the databases on the hosts involved.  See MySQL Reference Manual for details.
41
42 1 Anchi Cheng
You can set hosts on a particular subnet by only specify the network number portion such as '192.168' and use wild card for the host number portion to give '192.168.%.%' as the global host allowing connection.
43 14 Morgan Beeby
If appropriate, you can also use domain name with wild card, i.e., '%.mydomain.edu'
44 2 Anchi Cheng
45 12 Anchi Cheng
Start mysql command line interface in a terminal as root and access the database named mysql which manages users and permission. We assume that you have used autoinstaller here and hence the password for root using in mysql is not yet set.
46 1 Anchi Cheng
47 15 Anchi Cheng
For CentOS7 running mariadb
48
<pre>
49
mysql
50
</pre>
51
52
For CentOS6 running mysql
53 12 Anchi Cheng
<pre>
54
mysql mysql
55
</pre>
56
57 2 Anchi Cheng
At the mysql prompt execute the following commands:
58
<pre>
59 9 Anchi Cheng
CREATE USER usr_object@'192.168.%.%' IDENTIFIED BY 'YOUR_PASSWORD';
60 2 Anchi Cheng
GRANT ALTER, CREATE, INSERT, SELECT, UPDATE ON leginondb.* TO usr_object@'192.168.%.%';
61 1 Anchi Cheng
GRANT ALTER, CREATE, INSERT, SELECT, UPDATE ON projectdb.* TO usr_object@'192.168.%.%';
62
</pre>
63
64
<pre>
65 9 Anchi Cheng
CREATE USER usr_object@'localhost' IDENTIFIED BY 'YOUR_PASSWORD';
66 1 Anchi Cheng
GRANT ALTER, CREATE, INSERT, SELECT, UPDATE ON leginondb.* TO usr_object@'localhost';
67
GRANT ALTER, CREATE, INSERT, SELECT, UPDATE ON projectdb.* TO usr_object@'localhost';
68
</pre>
69 8 Anchi Cheng
70 11 Anchi Cheng
<pre>
71
flush privileges;
72
exit;
73
</pre>
74
75 10 Anchi Cheng
h3. Other changes if usr_object will be used all the time from now on in autoinstalled Leginon:
76 8 Anchi Cheng
77 1 Anchi Cheng
*webserver* myamiweb/config.php
78 8 Anchi Cheng
<pre>
79
define('DB_USER', 'usr_object');
80 13 Anchi Cheng
define('DB_USER','YOUR_PASSWORD');
81 8 Anchi Cheng
</pre> 
82
83 9 Anchi Cheng
*processing server* /etc/myami/sinedon.cfg or ,if it does not exist, see [[Configure_sinedoncfg]] for other possibilities
84 8 Anchi Cheng
<pre>
85
user: usr_object
86 9 Anchi Cheng
passwd: YOUR_PASSWORD
87 2 Anchi Cheng
</pre>
88
89
______
90
91
[[Web Server Installation|< Web Server Installation]] | [[Additional Database Server Setup after Web Server Installation| Additional Database Server Setup >]] 
92
93
94 1 Anchi Cheng
______