重启后生效
#开启 chkconfig iptables on #关闭 chkconfig iptables off #或者用下面的命令关闭 /sbin/chkconfig --level 2345 iptables off
即时生效
#开启 service iptables start #关闭 service iptables stop
查看防火墙是否开启
service iptables status
通常情况下,我们会使用以下SQL语句来更新字段值:
UPDATE mytable SET myfield='value' WHERE other_field='other_value';
但是,如果你想更新多行数据,并且每行记录的各字段值都是各不一样,你会怎么办呢?举个例子,我的博客有三个分类目录(免费资源、教程指南、橱窗展示),这些分类目录的信息存储在数据库表categories中,并且设置了显示顺序字段 display_order,每个分类占一行记录。如果我想重新编排这些分类目录的顺序,例如改成(教程指南、橱窗展示、免费资源),这时就需要更新categories表相应行的display_order字段,这就涉及到更新多行记录的问题了,刚开始你可能会想到使用循环执行多条UPDATE语句的方式,就像以下的php程序示例:
foreach ($display_order as $id => $ordinal) { $sql="UPDATE categories SET display_order = $ordinal WHERE id = $id"; mysql_query($sql); }
这种方法并没有什么任何错误,并且代码简单易懂,但是在循环语句中执行了不止一次SQL查询,在做系统优化的时候,我们总是想尽可能的减少数据库查询的次数,以减少资源占用,同时可以提高系统速度。幸运的是,还有更好的解决方案,只不过SQL语句稍微复杂点,但是只需执行一次查询即可,语法如下:
#linux sed -i 's#/kfs/#/kfs/test22/#g' `grep kfs -rl --include="*.php" --exclude="config.php" ./` #mac sed -i "" 's#/kfs/#/kfs/test22/#g' `grep kfs -rl --include="*.php" --exclude="config.php" ./`
参数解释:
sed:
-i 表示操作的是文件,``括起来的grep命令,表示将grep命令的的结果作为操作文件
s/yyyy/xxxx/表示查找yyyy并替换为xxxx,后面跟g表示一行中有多个yyyy的时候,都替换,而不是仅替换第一个
grep:
-r表示查找所有子目录
-l表示仅列出符合条件的文件名,用来传给sed命令做操作
--include="*.php" 表示仅查找php文件
exclude="config.php" 表示不查找config.php
./ 表示要查找的根目录为当前目录
首先到 http://mirrors.163.com/centos/6/os/x86_64/Packages/下载软件包。
必要下载的软件包有(以64位系统为例):
python-iniparse-0.3.1-2.1.el6.noarch.rpm
yum-3.2.29-40.el6.centos.noarch.rpm
yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm
[注] :版本不一定要最新的(http://mirrors.163.com/centos/6/os/x86_64/Packages/ 查找对应版本)
rpm -qa | grep yum | xargs rpm -e --nodeps
注:xargs是一条Unix和类Unix操作系统的常用命令。它的作用是将参数列表转换成小块分段传递给其他命令,以避免参数列表过长的问题
--nodeps 强制卸载,不管依赖性
rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm rpm -ivh yum-3.2.29-40.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm
[注] :最后2个需要一起安装,否则会出现依赖性错误
cd /etc/yum.repos.d/ wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
vim CentOS6-Base-163.repo %s#$releasever#6.6#g
ubuntu下没有比较好用的Mysql的GUI客户端,所以安装了phpmyadmin,安装步骤如下:
sudo apt-get install -y phpmyadmin
这时在地址栏里输入http://localhost/phpmyadmin/回车,会发现浏览器一片空白,这时需要修改一些目录的权限,如下:
sudo chown -R www-data:www-data /etc/phpmyadmin/ sudo chown -R www-data:www-data /usr/share/phpmyadmin/ sudo chown -R www-data:www-data /var/lib/phpmyadmin/
注:www-data:www-data是apache的用户和组
phpmyadmin有三种认证方式config,cookie和http,在cookie和http都需要输入密码,config方式是把用户名和密码写入配置文件,登录时无需输入用户名和密码,直接就可以登录,config的认证方式适合本地phpmyadmin用。
下面是config方式认证的部分配置文件(config.inc.php):
$dbname = 'yourip'; /* Authentication type */ $cfg['Servers'][$i]['auth_type'] = 'config'; $cfg['Servers'][$i]['user'] = 'youruser'; $cfg['Servers'][$i]['password'] = 'yourpassword'; /* Server parameters */ $cfg['Servers'][$i]['host'] = $dbname; $cfg['Servers'][$i]['connect_type'] = 'tcp'; $cfg['Servers'][$i]['compress'] = false; /* Select mysqli if your server has it */ $cfg['Servers'][$i]['extension'] = 'mysql'; /* Optional: User for advanced features */ $cfg['Servers'][$i]['controluser'] = 'pma'; $cfg['Servers'][$i]['controlpass'] = 'pmapass'; /* Optional: Advanced phpMyAdmin features */ $cfg['Servers'][$i]['pmadb'] = $dbname; $cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark'; $cfg['Servers'][$i]['relation'] = 'pma_relation'; $cfg['Servers'][$i]['table_info'] = 'pma_table_info'; $cfg['Servers'][$i]['table_coords'] = 'pma_table_coords'; $cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages'; $cfg['Servers'][$i]['column_info'] = 'pma_column_info'; $cfg['Servers'][$i]['history'] = 'pma_history'; $cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords'; /* Uncomment the following to enable logging in to passwordless accounts, * after taking note of the associated security risks. */ $cfg['Servers'][$i]['AllowNoPassword'] = TRUE; $i++;