环境:RHEL 6.4 + IEE 4.0.6
需求:IEE数据库之前是使用root用户部署和管理的,现在安全加固,将数据库交给普通用户iee来管理。
一、当前环境
IEE数据库安装向导:http://www.cnblogs.com/jyzhao/p/3963925.html
根据当前的IEE进程确定那些文件/文件夹权限需要修改:
```
[root@JingyuDB ~]# ps -ef|grep mysql|grep -v grep
root 4833 1 0 16:23 pts/0 00:00:00 /bin/sh /usr/local/infobright-4.0.6-x86_64/bin/mysqld_safe --defaults-file=/etc/my-ib.cnf --log-queries-not-using-indexes --user=root --pid-file=/oradata/app/iee/data/JingyuDB.pid
root 4981 4833 0 16:23 pts/0 00:00:00 /usr/local/infobright-4.0.6-x86_64/bin/mysqld --defaults-file=/etc/my-ib.cnf --basedir=/usr/local/infobright-4.0.6-x86_64 --datadir=/oradata/app/iee/data --user=root --log-queries-not-using-indexes --log-error=/oradata/app/iee/data.err --pid-file=/oradata/app/iee/data/JingyuDB.pid --socket=/tmp/mysql-ib.sock --port=5029
[root@JingyuDB ~]# ls -lh /etc/my-ib.cnf
-rw-r--r--. 1 root root 2.2K Jan 27 16:08 /etc/my-ib.cnf
[root@JingyuDB ~]# ls -lh /etc/init.d/mysqld-ib
-rwxr--r--. 1 root root 14K Sep 9 2013 /etc/init.d/mysqld-ib
[root@JingyuDB ~]# ls -lh /oradata/app|grep iee
drwxr-xr-x. 4 root root 4.0K Jan 27 16:09 iee
[root@JingyuDB ~]# ls -lh /usr/local|grep infobright
drwxr-xr-x. 11 root root 4.0K Jan 27 16:09 infobright-4.0.6-x86_64
```
上面用到的命令列表:
```
--查询IEE进程,根据mysql关键字
ps -ef|grep mysql|grep -v grep
--根据进程可以看到相关的各个文件/文件夹
ls -lh /etc/my-ib.cnf
ls -lh /etc/init.d/mysqld-ib
ls -lh /oradata/app|grep iee
ls -lh /usr/local|grep infobright
```
二、root用户改造成iee用户
1.创建iee用户
root用户创建iee用户并设定iee用户密码:
```
useradd iee
passwd iee
```
2.关闭数据库
root用户关闭数据库:
```
/etc/init.d/mysqld-ib stop
```
3.修改权限
root用户修改相关文件及文件夹的用户及用户组:
```
chown iee:iee /etc/my-ib.cnf
chown iee:iee /etc/init.d/mysqld-ib
chown -R iee:iee /usr/local/infobright-4.0.6-x86_64
chown -R iee:iee /oradata/app/iee
```
4.启动数据库
使用iee用户登录主机启动数据库:
```
/etc/init.d/mysql-ib start
```
此时再次查看IEE进程,确定进程已由普通用户iee管理控制:
```
[iee@JingyuDB ~]$ ps -ef|grep mysql|grep -v grep
iee 6769 1 0 16:39 pts/0 00:00:00 /bin/sh /usr/local/infobright-4.0.6-x86_64/bin/mysqld_safe --defaults-file=/etc/my-ib.cnf --log-queries-not-using-indexes --user=root --pid-file=/oradata/app/iee/data/JingyuDB.pid
iee 6915 6769 0 16:39 pts/0 00:00:00 /usr/local/infobright-4.0.6-x86_64/bin/mysqld --defaults-file=/etc/my-ib.cnf --basedir=/usr/local/infobright-4.0.6-x86_64 --datadir=/oradata/app/iee/data --log-queries-not-using-indexes --log-error=/oradata/app/iee/data.err --pid-file=/oradata/app/iee/data/JingyuDB.pid --socket=/tmp/mysql-ib.sock --port=5029
```
5.验证数据
mysql-ib登录进IEE数据库,验证数据确定没有问题:
```
[iee@JingyuDB ~]$ mysql-ib
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.1.40 build number (revision)=IB_4.0.6_r16086_16275(iee - commercial) (static)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| BH_RSI_Repository |
| jingyu |
| mysql |
| sys_infobright |
| test |
+--------------------+
6 rows in set (0.01 sec)
mysql> use jingyu
Database changed
mysql> show tables;
+------------------+
| Tables_in_jingyu |
+------------------+
| T1 |
| t1 |
+------------------+
2 rows in set (0.00 sec)
mysql> select count(1) from T1;
+----------+
| count(1) |
+----------+
| 4 |
+----------+
1 row in set (0.00 sec)
mysql>
至此,完成IEE数据库交付给普通用户iee来管理维护。