Centos5.2配置LAMP与Centos5.3配置LAMP

2020-01-30 12:46:46丽君

首先先登录mysql,在终端窗口输入 /usr/local/mysql/bin/mysql -u root -p
然后会提示输入密码,输入正确密码后,会出现mysql>提示符。
输入以下命令:
mysql>use mysql;
mysql>update user set user="centos" where user="root"; (将mysql的root用户名修改成centos,防止root的密码被暴力破解)
mysql>select Host,User,Password,Select_priv,Grant_priv from user;
mysql>delete from user where user=''; (删除user用户)
mysql>delete from user where password=''; (删除user用户)
mysql>delete from user where host=''; (删除user用户)
mysql>drop database test; (删除默认的test数据库)
mysql>flush privileges; (刷新mysql的缓存,让以上设置立即生效)
mysql>quit;
为了使以上优化和安全设置生效,请重启Mysql服务或Linux。
关于Mysql的安全设置,这篇文章很值得一看
http://www.unixren.com/linux/bencandy.php?fid=21&id=459

22、操作系统安全调整
1、 CentOS或Red Had Enterprise Linux 4 的用户要首先要打开SElinux,方法是修改/etc/selinux/config文件中的SELINUX="" 为enforcing 。它可以保证你的系统不会非正常的崩溃。有些人认为应该关闭,我强烈不推荐,当然只是将centos用来玩玩,不是用于实际服务器则无所谓了。
2、启用iptables 防火墙,对增加系统安全有许多好处。设置好防火墙的规则。
3、执行setup 关闭那些不需要的服务 ,记住少开一个服务,就少一个危险。
4、禁止Control-Alt-Delete 键盘关闭命令
在"/etc/inittab" 文件中注释掉下面这行(使用#):
ca::ctrlaltdel:/sbin/shutdown -t3 -r now 
改为:
#ca::ctrlaltdel:/sbin/shutdown -t3 -r now 
为了使这项改动起作用,输入下面这个命令:
# /sbin/init q
5、给"/etc/rc.d/init.d" 下script文件设置权限
给执行或关闭启动时执行的程序的script文件设置权限。
# chmod -R 700 /etc/rc.d/init.d/* 
这表示只有root才允许读、写、执行该目录下的script文件。
6、修改"/etc/host.conf"文件
"/etc/host.conf"说明了如何解析地址。编辑"/etc/host.conf"文件(vi /etc/host.conf),加入下面这行:
# Lookup names via DNS first then fall back to /etc/hosts. 
order bind,hosts 
# We have machines with multiple IP addresses. 
multi on 
# Check for IP address spoofing. 
nospoof on 
第一项设置首先通过DNS解析IP地址,然后通过hosts文件解析。第二项设置检测是否"/etc/hosts"文件中的主机是否拥有多个IP地址(比如有多个以太口网卡)。第三项设置说明要注意对本机未经许可的电子欺骗。