您好,登錄后才能下訂單哦!
服務器運行環境:
操作系統:CentOS release 6.8 (Final)
Web服務器軟件:Apache/2.2.15 (Unix)
數據庫系統:MySQL 5.1.73
對默認的CactiEZi中文版進行數據庫安全方面的優化。
mysql> select host,user,password from user;
+-----------------------+-----------+-------------------------------------------+
| host | user | password |
+-----------------------+-----------+-------------------------------------------+
| localhost | root | |
| localhost.localdomain | root | |
| 127.0.0.1 | root | |
| localhost | | |
| localhost.localdomain | | |
| localhost | cactiuser | *43DD7940383044FBDE5B177730FAD3405BC6DAD7 |
| % | cactiuser | *43DD7940383044FBDE5B177730FAD3405BC6DAD7 |
| % | cacti | *9CDE1A09ED38FCFD4696D1AA82E4E1EE2F26270D |
+-----------------------+-----------+-------------------------------------------+
8 rows in set (0.00 sec)
mysql> select host,db,user from db;
+-----------+---------+-----------+
| host | db | user |
+-----------+---------+-----------+
| % | cacti | cacti |
| % | cacti | cactiuser |
| % | test | |
| % | test\_% | |
| localhost | cacti | cactiuser |
+-----------+---------+-----------+
通過以上圖,我要解決兩個問題:
1.默認登錄數據庫,不需要密碼,看到上述表得知,原因是root用戶沒有設置密碼;
2.Cacti程序連接數據庫對用的是cactiuser用戶賬號,在這里做出修改,提升數據庫安全性。
mysql> update user set password=password("****") where user="root"; #更改root用戶密碼
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql>select host,user,password from user;
+
| host | user | password |
+-----------------------+-----------+-------------------------------------------+
| localhost | root | *1F20AD266C1753F805F6A4A6CDF34C72153C86FB |
| localhost.localdomain | root | *1F20AD266C1753F805F6A4A6CDF34C72153C86FB |
| 127.0.0.1 | root | *1F20AD266C1753F805F6A4A6CDF34C72153C86FB |
mysql> flush privileges;
mysql> exit
[root@Cacti /]# mysql -uroot -p #必須輸入密碼才能登錄數據庫
Enter password:
mysql> use mysql;
mysql> update user set password=password("***") where host="%" and user="cactiuser";Query OK, 1 row affected (0.00 sec)Rows matched: 1 Changed: 1 Warnings: 0
#請注意該host="%" 修改密碼后,并不影響程序連接數據庫;
mysql> update user set password=password("***") where host="localhost" and user="cactiuser";
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
#請注意,cacti程序的host主機是localhost,對用此項修改密碼才有效果;
mysql> select host,user,password from user;
+-----------------------+-----------+-------------------------------------------+
| host | user | password |
+-----------------------+-----------+-------------------------------------------+
| localhost | root | *1F20AD266C1753F805F6A4A6CDF34C72153C86FB |
| localhost.localdomain | root | *1F20AD266C1753F805F6A4A6CDF34C72153C86FB |
| 127.0.0.1 | root | *1F20AD266C1753F805F6A4A6CDF34C72153C86FB |
| localhost | | |
| localhost.localdomain | | |
| localhost | cactiuser | *1F20AD266C1753F805F6A4A6CDF34C72153C86FB |
| % | cactiuser | *43DD7940383044FBDE5B177730FAD3405BC6DAD7 |
| % | cacti | *9CDE1A09ED38FCFD4696D1AA82E4E1EE2F26270D |
數據庫中修改了用戶的密碼,所以程序配置文件也要修改對應的賬號。
# vi /var/www/html/include/config.php
$database_type = "mysql";
$database_default = "數據庫名";
$database_hostname = "localhost";
$database_username = "用戶名";
$database_password ="密碼";
$database_port = "3306";
到此步為止,所有配置成功。
一個建議,root用戶用于整個數據庫系統管理,業務系統另建賬戶。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。