<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>运达&#039;s  blog &#187; Mysql</title>
	<atom:link href="https://www.yunda51.com/?feed=rss2&#038;tag=mysql" rel="self" type="application/rss+xml" />
	<link>https://www.yunda51.com</link>
	<description>运达的博客</description>
	<lastBuildDate>Wed, 12 Nov 2025 07:58:26 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.0.19</generator>
	<item>
		<title>MySQL编译安装及主从同步</title>
		<link>https://www.yunda51.com/?p=1802</link>
		<comments>https://www.yunda51.com/?p=1802#comments</comments>
		<pubDate>Tue, 12 Sep 2017 07:04:00 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[centos]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1802</guid>
		<description><![CDATA[1、上传cmake-2.8.8.tar.gz mysql-5.5.25.tar.gz 2、安装编译MySQL过<a href="https://www.yunda51.com/?p=1802" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>1、上传cmake-2.8.8.tar.gz mysql-5.5.25.tar.gz</p>
<p>2、安装编译MySQL过程中需要的依赖包：</p>
<pre class="wp-code-highlight prettyprint">
yum install ncurses-devel libaio-devel -y
yum install gcc-c++ -y
</pre>
<p>3、安装编译安装需要的软件：</p>
<pre class="wp-code-highlight prettyprint">
cd /app/tool/
tar zxvf cmake-2.8.8.tar.gz
cd cmake-2.8.8
./configure 
gmake
gmake install
</pre>
<p>4、开始安装MySQL，在主服务器上搭建MySQL：</p>
<pre class="wp-code-highlight prettyprint">
useradd mysql -s /sbin/nologin -M
tar zxf mysql-5.5.25.tar.gz 
cd mysql-5.5.25
cmake . -DCMAKE_INSTALL_PREFIX=/app/soft/mysql-5.5.25 \
-DMYSQL_DATADIR=/app/soft/mysql-5.5.25/data \
-DMYSQL_UNIX_ADDR=/app/soft/mysql-5.5.25/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FAST_MUTEXES=1 \
-DWITH_ZLIB=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DWITH_DEBUG=0

make   
make install
ln -s mysql-5.5.25/ /app/soft/mysql     //创建MySQL软连接
echo &#039;PATH=&quot;/app/soft/mysql/bin/:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin&quot;&#039;&gt;&gt;/etc/profile
. /etc/profile
</pre>
<p>5、配置MySQL初始数据，并启动:</p>
<pre class="wp-code-highlight prettyprint">
chmod 755 /app/soft/mysql/scripts/mysql_install_db 

/app/soft/mysql/scripts/mysql_install_db --basedir=/app/soft/mysql/ --datadir=/app/soft/mysql/data/ --user=mysql
##如果在这个环节出现了/app/soft/mysql/scripts/mysql_install_db 不存在的报错时，重新进行编译安装。

cp /app/soft/mysql/support-files/my-small.cnf /etc/my.cnf

cp /app/soft/mysql/support-files/mysql.server /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld   //授予执行的权限

mysql_secure_installation #设置Mysql密码

/etc/init.d/mysqld start  //重新启动
</pre>
<p>至此，MySQL编译安装完成。</p>
<p><strong>搭建从库：</strong></p>
<p>按照主库的流程安装从库。<br />
配置主从关系<br />
设置好my.cnf的配置文件<br />
主数据库的配置文件：</p>
<pre class="wp-code-highlight prettyprint">
[root@db01 ~]# cat /etc/my.cnf

[client]
port		= 3306
socket		= /app/soft/mysql-5.5.25/tmp/mysql.sock


[mysqld]
port		= 3306
socket		= /app/soft/mysql-5.5.25/tmp/mysql.sock
skip-external-locking
key_buffer_size = 384M
max_allowed_packet = 1M
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M
log-slow-queries=/data/mysqldata/slowquery.log

long_query_time=1
thread_concurrency = 8


log-bin=mysql-bin
server-id	= 1
expire-logs-days = 7
relay-log-space-limit           = 16G
slave-skip-errors = 1032,1062,126,1114,1146,1048,1396,2003 


[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout
</pre>
<p>从数据库的配置文件:</p>
<pre class="wp-code-highlight prettyprint">
[root@db02 ~]# cat /etc/my.cnf
[client]
port		= 3306
socket		= /app/soft/mysql-5.5.25/tmp/mysql.sock


[mysqld]
port		= 3306
socket		= /app/soft/mysql-5.5.25/tmp/mysql.sock
skip-external-locking
key_buffer_size = 384M
max_allowed_packet = 1M
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M
log-slow-queries=/data/mysqldata/slowquery.log

long_query_time=1
thread_concurrency = 8

#log-bin=mysql-bin
server-id	= 2
slave-skip-errors = 1032,1062,126,1114,1146,1048,1396

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout
</pre>
<p>进入到主数据库:</p>
<pre class="wp-code-highlight prettyprint">
mysql
useradd liuyd  //创建liuyd用户
id liuyd      //查看liuyd
su - liuyd    //切换用户
passwd        //设置密码
grant replication slave on *.* to liuyd@&#039;192.168.199.%&#039; identified by &#039;123456&#039;;
flush privileges;
</pre>
<p>锁表导出数据：</p>
<pre class="wp-code-highlight prettyprint">
flush table with read lock;
\q
mysqldump -uroot -A -B --events |gzip &gt;/server/backup/repl_bak_$(date +%F).sql.gz
</pre>
<p>将导出的数据传到从库上面去并解压导入到数据库中：</p>
<pre class="wp-code-highlight prettyprint">
scp -a /server/backup/repl_bak_$(date +%F).sql.gz root@192.168.199.160:/server/backup/
mysql &lt; /server/backup/repl_bak_$(date +%F).sql.gz
</pre>
<p>进入到从库：</p>
<pre class="wp-code-highlight prettyprint">
mysql
stop slave;
CHANGE MASTER TO  
MASTER_HOST=&#039;192.168.199.159&#039;, 
MASTER_PORT=3306,
MASTER_USER=&#039;rep&#039;, 
MASTER_PASSWORD=&#039;oldboy123456&#039;, 
MASTER_LOG_FILE=&#039;mysql-bin.000010&#039;,
MASTER_LOG_POS=245;
start slave;
show slave status\G;
#             Slave_IO_Running: Yes
#             Slave_SQL_Running: Yes
#             Seconds_Behind_Master: 0
</pre>
<p>##出现以上数据，同步成功。</p>
<p>转载请注明转自:<a href="http://www.yunda51.com">运达's blog</a> 原文地址：<a href="http://www.yunda51.com/1802.html">http://www.yunda51.com/1802.html</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1802</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mysql show processlist 详解</title>
		<link>https://www.yunda51.com/?p=1751</link>
		<comments>https://www.yunda51.com/?p=1751#comments</comments>
		<pubDate>Thu, 09 Mar 2017 09:55:33 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1751</guid>
		<description><![CDATA[mysql&#62; show processlist; +—–+————-+——————–+ &#124; Id &#124; U<a href="https://www.yunda51.com/?p=1751" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<pre class="wp-code-highlight prettyprint">
    mysql&gt; show processlist;
    +—–+————-+——————–+
    | Id | User | Host | db | Command | Time| State | Info
    +—–+————-+——————–+
    |207|root |192.168.0.2:51621 |mytest | Sleep | 5 | | NULL
    |208|root |192.168.0.2:51622 |mytest | Sleep | 5 | | NULL
    |220|root |192.168.0.2:51676 |mytest |Query | 84 | locked |
    select name,culture,value,type from book where id=1
</pre>
<p>说明各列的含义和用途，</p>
<pre class="wp-code-highlight prettyprint">
  id列:一个标识，你要kill 一个语句的时候很有用。
  user列: 显示当前用户，如果不是root，这个命令就只显示你权限范围内的sql语句。
  host列:显示这个语句是从哪个ip 的哪个端口上发出的。可用来追踪出问题语句的用户。
  db列:显示这个进程目前连接的是哪个数据库。
  command列:显示当前连接的执行的命令，一般就是休眠（sleep），查询（query），连接（connect）。
  time列:此这个状态持续的时间，单位是秒。
  state列:显示使用当前连接的sql语句的状态，很重要的列，后续会有所有的状态的描述，
  请注意，state只是语句执行中的某一个状态，一个sql语句，已查询为例，可能需要经过
  copying to tmp table，Sorting result，Sending data等状态才可以完成。
</pre>
<p>这个命令中最关键的就是state列，mysql列出的状态主要有以下几种：</p>
<pre class="wp-code-highlight prettyprint">
     Checking table
    正在检查数据表（这是自动的）。
    Closing tables
    正在将表中修改的数据刷新到磁盘中，同时正在关闭已经用完的表。这是一个很快的操作，
    如果不是这样的话，就应该确认磁盘空间是否已经满了或者磁盘是否正处于重负中。
    Connect Out
    复制从服务器正在连接主服务器。
    Copying to tmp table on disk
    由于临时结果集大于 tmp_table_size，正在将临时表从内存存储转为磁盘存储以此节省内存。
    Creating tmp table
    正在创建临时表以存放部分查询结果。
    deleting from main table
    服务器正在执行多表删除中的第一部分，刚删除第一个表。
    deleting from reference tables
    服务器正在执行多表删除中的第二部分，正在删除其他表的记录。
    Flushing tables
    正在执行 FLUSH TABLES，等待其他线程关闭数据表。
    Killed
    发送了一个kill请求给某线程，那么这个线程将会检查kill标志位，同时会放弃下一个kill请求。
    MySQL会在每次的主循环中检查kill标志位，不过有些情况下该线程可能会过一小段才能死掉。
    如果该线程程被其他线程锁住了，那么kill请求会在锁释放时马上生效。
    Locked
    被其他查询锁住了。
    Sending data
    正在处理 SELECT 查询的记录，同时正在把结果发送给客户端。
    Sorting for group
    正在为 GROUP BY 做排序。
    Sorting for order
    正在为 ORDER BY 做排序。
    Opening tables
    这个过程应该会很快，除非受到其他因素的干扰。例如，在执 ALTER TABLE 或 LOCK TABLE 语句行完以前，数据表无法被其他线程打开。 正尝试打开一个表。
    Removing duplicates
    正在执行一个 SELECT DISTINCT 方式的查询，但是MySQL无法在前一个阶段优化掉那些重复的记录。因此，MySQL需要再次去掉重复的记录，然后再把结果发送给客户端。
    Reopen table
    获得了对一个表的锁，但是必须在表结构修改之后才能获得这个锁。已经释放锁，关闭数据表，正尝试重新打开数据表。
    Repair by sorting
    修复指令正在排序以创建索引。
    Repair with keycache
    修复指令正在利用索引缓存一个一个地创建新索引。它会比 Repair by sorting 慢些。
    Searching rows for update
    正在讲符合条件的记录找出来以备更新。它必须在 UPDATE 要修改相关的记录之前就完成了。
    Sleeping
    正在等待客户端发送新请求.
    System lock
    正在等待取得一个外部的系统锁。如果当前没有运行多个 mysqld 服务器同时请求同一个表，那么可以通过增加 –skip-external-locking参数来禁止外部系统锁。
    Upgrading lock
    INSERT DELAYED 正在尝试取得一个锁表以插入新记录。
    Updating
    正在搜索匹配的记录，并且修改它们。
    User Lock
    正在等待 GET_LOCK()。
    Waiting for tables
    该线程得到通知，数据表结构已经被修改了，需要重新打开数据表以取得新的结构。然后，为了能的重新打开数据表，必须等到所有其他线程关闭这个表。以下几种情况下会产生这个通知：FLUSH TABLES tbl_name, ALTER TABLE, RENAME TABLE, REPAIR TABLE, ANALYZE TABLE, 或 OPTIMIZE TABLE。
    waiting for handler insert
    INSERT DELAYED 已经处理完了所有待处理的插入操作，正在等待新的请求。
    大部分状态对应很快的操作，只要有一个线程保持同一个状态好几秒钟，那么可能是有问题发生了，需要检查一下。还有其它的状态没在上面中列出来，不过它们大部分只是在查看服务器是否有存在错误是才用得着。
</pre>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1751</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Navicat远程连接虚拟机Mysql的时候报错mysql 1130的解决方法</title>
		<link>https://www.yunda51.com/?p=1642</link>
		<comments>https://www.yunda51.com/?p=1642#comments</comments>
		<pubDate>Tue, 01 Sep 2015 07:06:43 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[Mysql]]></category>
		<category><![CDATA[liunx]]></category>
		<category><![CDATA[navicta]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1642</guid>
		<description><![CDATA[闲来无事，在自己笔记本上安装了虚拟机并且配置了nginx+php+mysql，这些东西都已顺利搭建，唯一的一点<a href="https://www.yunda51.com/?p=1642" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>闲来无事，在自己笔记本上安装了虚拟机并且配置了nginx+php+mysql，这些东西都已顺利搭建，唯一的一点就见表的时候不方便，所以用navicta工具连接自己虚拟机的mysql，结果出现了如下问题：<strong>ERROR 1130: Host '192.168.116.128' is not allowed to connect to this MySQL server（不允许连接到MySQL服务器，也就是没有给用户授权）</strong></p>
<p>经过研究找到了解决方法：</p>
<p>1、首先给用户授权，</p>
<p>我用的用户是root 密码123456</p>
<p>然后进入到mysql里面：mysql -uroot -p123456</p>
<p>进入之后，首选语法为:<br />
Sql代码 ：<br />
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;</p>
<p>执行代码。如图：</p>
<p><a href="http://www.yunda51.com/wp-content/uploads/2015/09/nav6.png"><img class="alignnone size-full wp-image-1645" src="http://www.yunda51.com/wp-content/uploads/2015/09/nav6.png" alt="nav6" width="834" height="76" /></a></p>
<p>示例: Sql代码<br />
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;</p>
<p>执行完后,再<br />
flush privileges;</p>
<p>如图：<a href="http://www.yunda51.com/wp-content/uploads/2015/09/push6.png"><img class="alignnone size-full wp-image-1646" src="http://www.yunda51.com/wp-content/uploads/2015/09/push6.png" alt="push6" width="371" height="64" /></a></p>
<p>&nbsp;</p>
<p>刷新一下权限就可以了,不用重启。</p>
<p>现在你在用navicta工具连接你虚拟机的mysql已经ok了！</p>
<p>转载请注明转自:<a href="http://www.yunda51.com">运达's blog</a> 原文地址：<a href="http://www.yunda51.com/1470.html">http://www.yunda51.com/1642.html</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1642</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>CentOs下memcache的安装以及php添加memcache扩展</title>
		<link>https://www.yunda51.com/?p=1610</link>
		<comments>https://www.yunda51.com/?p=1610#comments</comments>
		<pubDate>Tue, 18 Aug 2015 16:03:37 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[memcache]]></category>
		<category><![CDATA[Mysql]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1610</guid>
		<description><![CDATA[一、下载需要的源码包 1、 下载libevent2.0.22                   2、 下载m<a href="https://www.yunda51.com/?p=1610" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>一、下载需要的源码包<br />
1、 下载libevent2.0.22                  <a style="background: transparent none repeat scroll 0% 0%;" href="http://pan.baidu.com/s/1sjIEu1v" target=""><img class="alignnone size-full wp-image-1075" title="btn_load" src="http://www.yunda51.com/wp-content/uploads/2013/11/btn_load3.png" alt="" width="86" height="28" /></a><br />
2、 下载memcached1.4.24           <a style="background: transparent none repeat scroll 0% 0%;" href="http://pan.baidu.com/s/1kTF2Mz1" target=""><img class="alignnone size-full wp-image-1075" title="btn_load" src="http://www.yunda51.com/wp-content/uploads/2013/11/btn_load3.png" alt="" width="86" height="28" /></a><br />
3、 下载php扩展memcache3.0.8  <a style="background: transparent none repeat scroll 0% 0%;" href="http://pan.baidu.com/s/1gdwDZaj" target=""><img class="alignnone size-full wp-image-1075" title="btn_load" src="http://www.yunda51.com/wp-content/uploads/2013/11/btn_load3.png" alt="" width="86" height="28" /></a></p>
<p>二、安装详细步骤<br />
首先将以上下载的三个软件包下载到/usr/local/src目录下（注：你们可以放到别的目录）<br />
1. 安装libevent<br />
cd /usr/local/src<br />
tar zxvf libevent-2.0.22-stable.tar.gz #解压包<br />
cd libevent-2.0.22-stable<br />
./configure --prefix=/usr/local #编译前配置，生成Makefile文件，路径可自行更改<br />
make #编译<br />
make install #安装</p>
<p>2、安装memcached<br />
cd /usr/local/src<br />
tar zxvf memcached-1.4.24.tar.gz #解压包<br />
cd memcached-1.4.24<br />
./configure –with-libevent=/usr/local #编译前配置，生成Makefile文件，路径必须与libevent中一致<br />
make #编译<br />
make install #安装</p>
<p>（注：如果在make 编译的时候报错，出现如图：）<br />
<a href="http://www.yunda51.com/wp-content/uploads/2015/08/11.png"><img class="alignnone size-full wp-image-1614" src="http://www.yunda51.com/wp-content/uploads/2015/08/11.png" alt="1" width="558" height="92" /></a></p>
<p>解决办法：<br />
1、cd /usr/local/memcached-1.4.24 进入memcached目录<br />
2、vi Makefile （编辑Makefile文件，删除文件中的“-Werror” ，保存后即可。）<br />
3、保存之后，接着安装 make install。<br />
测试是否安装成功。<br />
如图：<a href="http://www.yunda51.com/wp-content/uploads/2015/08/21.png"><img class="alignnone size-full wp-image-1615" src="http://www.yunda51.com/wp-content/uploads/2015/08/21.png" alt="2" width="558" height="36" /></a><br />
3、安装扩展<br />
1、cd /usr/local/src<br />
2、tar zxvf memcache-3.0.8.tgz<br />
3、memcache-3.0.8<br />
4、/usr/local/php5/bin/phpize #执行phpize扩展安装程序<br />
如图：<a href="http://www.yunda51.com/wp-content/uploads/2015/08/22.png"><img class="alignnone size-full wp-image-1623" src="http://www.yunda51.com/wp-content/uploads/2015/08/22.png" alt="2" width="689" height="138" /></a><br />
5、./configure -enable-memcache -with-php-config=/usr/local/php5/bin/php-config -with-zlib-dir<br />
6、make #编译<br />
7、make install #安装<br />
如图： <a href="http://www.yunda51.com/wp-content/uploads/2015/08/4.png"><img class="alignnone size-full wp-image-1617" src="http://www.yunda51.com/wp-content/uploads/2015/08/4.png" alt="4" width="558" height="49" /></a><br />
三 、配置php.ini文件<br />
1、 查看是否有memcache.so<br />
cd /usr/local/lib/php/extensions/no-debug-non-zts-20100525/<br />
2、vi /usr/local/php5/etc/php.ini #编辑php.ini<br />
添加如下代码：<br />
extension=memcache.so<br />
[Memcache]<br />
extension_dir =“/usr/local/lib/php/extensions/no-debug-non-zts-20100525/”<br />
memcache.allow_failover = 1<br />
memcache.max_failover_attempts=20<br />
memcache.chunk_size =8192</p>
<p>四、配置memcached服务器<br />
1、启动memcached服务器<br />
memcached -d -m 10 -u root -l 127.0.0.1 -p 11211 -c 256 -P /usr/local/bin/memcached/memcached.pid</p>
<p>如果在启动memcached时候报“memcached: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory”之类的错误信息，表示memcached找不到libevent的位置<br />
<strong>如图：</strong><br />
<a href="http://www.yunda51.com/wp-content/uploads/2015/08/memcached.png"><img class="alignnone size-full wp-image-1620" src="http://www.yunda51.com/wp-content/uploads/2015/08/memcached.png" alt="memcached" width="558" height="34" /></a></p>
<p><strong>解决办法： </strong><br />
1、 首先查看，libevent 在哪里 ，执行：# whereis libevent<br />
2、 然后，再看memcached 从哪里找它，执行# LD_DEBUG=libs memcached -v 2&gt;&amp;1 &gt; /dev/null | less 可以看到：是/usr/lib/libevent-2.0.so.5，所以，创建软链<br />
3、 # ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5<br />
4、 关闭memcached :pkill memcached<br />
5、 再次启动：memcached -d -m 10 -u root -l 127.0.0.1 -p 11211 -c 256 -P /usr/local/bin/memcached/memcached.pid<br />
6、 查看端口，看memcached是否启动成功！# netstat –ant<br />
如图：<br />
<a href="http://www.yunda51.com/wp-content/uploads/2015/08/memcached1.png"><img class="alignnone size-full wp-image-1621" src="http://www.yunda51.com/wp-content/uploads/2015/08/memcached1.png" alt="memcached1" width="558" height="162" /></a><br />
表示启动成功！<br />
7、查看你得memcache扩展是否添加成功！<br />
如图：<a href="http://www.yunda51.com/wp-content/uploads/2015/08/12.png"><img class="alignnone size-full wp-image-1622" src="http://www.yunda51.com/wp-content/uploads/2015/08/12.png" alt="1" width="661" height="241" /></a><br />
表示扩展添加成功！<br />
五 测试php的memcache扩展<br />
<!--?php $mem = new Memcache(); $mem--->connect("127.0.0.1", 11211);<br />
$mem-&gt;set('key', 'This is my  memcache ceshi!', 0, 60);<br />
$val = $mem-&gt;get('key');<br />
echo $val;<br />
?&gt;</p>
<p>转载请注明转自:<a href="http://www.yunda51.com">运达's blog</a> 原文地址：<a href="http://www.yunda51.com/1470.html">http://www.yunda51.com/1610.html</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1610</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CentOs编译安装LNMP环境(nginx+mysql+php)</title>
		<link>https://www.yunda51.com/?p=1583</link>
		<comments>https://www.yunda51.com/?p=1583#comments</comments>
		<pubDate>Wed, 12 Aug 2015 08:45:03 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1583</guid>
		<description><![CDATA[准备工作：1、配置好IP、DNS 、网关，确保使用远程连接工具能够连接服务器 2、配置防火墙，开启80端口、3<a href="https://www.yunda51.com/?p=1583" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>准备工作：1、配置好IP、DNS 、网关，确保使用远程连接工具能够连接服务器<br />
2、配置防火墙，开启80端口、3306端口<br />
vi /etc/sysconfig/iptables #编辑防火墙配置文件</p>
<pre class="wp-code-highlight prettyprint">    
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT（允许80端口通过防火墙）    
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT（允许3306端口通过防火墙）    
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT    
</pre>
<p><strong>下载软件包</strong></p>
<p>1.下载nginx</p>
<p>http://nginx.org/download/nginx-1.2.0.tar.gz</p>
<p>2、下载pcre （支持nginx伪静态）<br />
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz</p>
<p>3、下载MySQL（目前稳定版）</p>
<p>http://mysql.mirror.kangaroot.net/Downloads/MySQL-5.5/mysql-5.5.25.tar.gz</p>
<p>由于版本更新可能以前版本已不存在，可http://mysql.mirror.kangaroot.net/Downloads下载相应版本。</p>
<p>4、下载php</p>
<p>http://www.php.net/releases/</p>
<p>5、下载cmake（MySQL编译工具）</p>
<p>http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz</p>
<p>6、下载libmcrypt（PHPlibmcrypt模块）<br />
ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz</p>
<p>安装编译工具及库文件（使用CentOS yum命令安装）</p>
<pre class="wp-code-highlight prettyprint">yum install make apr* autoconf automake curl-devel gcc gcc-c++ zlib-devel openssl openssl-devel pcre
-devel gd  kernel keyutils  patch  perl kernel-headers compat* mpfrcpp glibc libgomp libstdc++-devel
 ppl cloog-ppl keyutils-libs-devel libcom_err-devellibsepol-devel libselinux-devel krb5-devel zlib-devel 
libXpm* freetype libjpeg* libpng* php-common php-gd ncurses* libtool* libxml2 libxml2-devel patch
freetype-devel
</pre>
<p><strong>安装cmake</strong></p>
<p>cd /usr/local/src</p>
<p>tar zxvf cmake-2.8.8.tar.gz</p>
<p>cd cmake-2.8.8</p>
<p>./configure make #编译</p>
<p>make install #安装</p>
<p><strong>安装MySQL</strong></p>
<p>groupadd mysql #添加mysql组</p>
<p>useradd -g mysql mysql -s /bin/false #创建用户mysql并加入到mysql组，不允许mysql用户直接登录系统</p>
<p>mkdir -p /data/mysql #创建MySQL数据库存放目录</p>
<p>chown -R mysql:mysql /data/mysql #设置MySQL数据库目录权限</p>
<p>mkdir -p /usr/local/mysql #创建MySQL安装目录</p>
<p>cd /usr/local/src</p>
<p>tar zxvf mysql-5.5.25.tar.gz #解压</p>
<p>cd mysql-5.5.25</p>
<p>cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc #配置</p>
<p>make #编译</p>
<p>make install #安装</p>
<p>cd /usr/local/mysql</p>
<p>cp ./support-files/my-huge.cnf /etc/my.cnf #拷贝配置文件（注意：如果/etc目录下面默认有一个my.cnf，直接覆盖即可）</p>
<p>vi /etc/my.cnf #编辑配置文件,在 [mysqld] 部分增加下面一行</p>
<p>datadir = /data/mysql #添加MySQL数据库路径</p>
<p>:wq! #保存退出</p>
<p>./scripts/mysql_install_db --user=mysql #生成mysql系统数据库</p>
<p>cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld #把Mysql加入系统启动</p>
<p>chmod 755 /etc/init.d/mysqld #增加执行权限</p>
<p>chkconfig mysqld on #设置开机启动</p>
<p>vi /etc/rc.d/init.d/mysqld #编辑</p>
<p>basedir = /usr/local/mysql #MySQL程序安装路径</p>
<p>datadir = /data/mysql #MySQl数据库存放目录</p>
<p>service mysqld start #启动</p>
<p>vi /etc/profile #把mysql服务加入系统环境变量：在最后添加下面这一行</p>
<p>export PATH=$PATH:/usr/local/mysql/bin</p>
<p>:wq! #保存退出</p>
<p>下面这两行把myslq的库文件链接到系统默认的位置，在编译类似PHP等软件时可以不用指定mysql的库文件地址。</p>
<p>ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql</p>
<p>ln -s /usr/local/mysql/include/mysql /usr/include/mysql</p>
<p>shutdown -r now #需要重启系统，等待系统重新启动之后继续在终端命令行下面操作</p>
<p>mysql_secure_installation #设置Mysql密码</p>
<p>根据提示按Y 回车（默认密码为空）</p>
<p>然后输入2次密码</p>
<p>继续按Y 回车，直到设置完成</p>
<p>或者直接修改密码/usr/local/mysql/bin/mysqladmin -u root -p password "123456" #修改密码</p>
<p>service mysqld restart #重启</p>
<p>到此，mysql安装完成！</p>
<p><strong>安装pcre</strong></p>
<p>cd /usr/local/src</p>
<p>mkdir /usr/local/pcre #创建安装目录</p>
<p>tar zxvf pcre-8.30.tar.gz</p>
<p>cd pcre-8.30</p>
<p>./configure --prefix=/usr/local/pcre #配置</p>
<p>make</p>
<p>make install</p>
<p><strong>安装libmcrypt</strong></p>
<p>cd /usr/local/src</p>
<p>tar zxvf libmcrypt-2.5.7.tar.gz #解压</p>
<p>cd libmcrypt-2.5.7 #进入目录</p>
<p>./configure #配置</p>
<p>make #编译</p>
<p>make install #安装</p>
<p><strong>安装 nginx</strong></p>
<p>cd /usr/local/src</p>
<p>groupadd www #添加www组</p>
<p>useradd -g www www -s /bin/false #创建nginx运行账户www并加入到www组，不允许www用户直接登录系统</p>
<p>tar zxvf nginx-1.9.3.tar.gz</p>
<p>cd nginx-1.9.3</p>
<p>./configure --prefix=/usr/local/nginx --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-openssl=/usr/ --with-pcre=/usr/local/src/pcre-8.37</p>
<p>#注意:--with-pcre=/usr/local/src/pcre-8.37指向的是源码包解压的路径，而不是安装的路径，否则会报错</p>
<p>make</p>
<p>make install</p>
<p>/usr/local/nginx/sbin/nginx #启动nginx</p>
<p>vi /etc/rc.d/init.d/nginx #设置nginx开启启动，编辑启动文件添加下面内容</p>
<pre class="wp-code-highlight prettyprint">    ##############################################
        #!/bin/sh  
    #  
    # nginx - this script starts and stops the nginx daemin  
    #  
    # chkconfig:   - 85 15  
    # description:  Nginx is an HTTP(S) server, HTTP(S) reverse \  
    #               proxy and IMAP/POP3 proxy server  
    # processname: nginx  
    # config:      /usr/local/nginx/conf/nginx.conf  
    # pidfile:     /usr/local/nginx/logs/nginx.pid  
      
    # Source function library.  
    . /etc/rc.d/init.d/functions  
      
    # Source networking configuration.  
    . /etc/sysconfig/network  
      
    # Check that networking is up.  
    [ &quot;$NETWORKING&quot; = &quot;no&quot; ] &amp;amp;&amp;amp; exit 0  
      
    nginx=&quot;/usr/local/nginx/sbin/nginx&quot;  
    prog=$(basename $nginx)  
      
    NGINX_CONF_FILE=&quot;/usr/local/nginx/conf/nginx.conf&quot;  
      
    lockfile=/var/lock/subsys/nginx  
      
    start() {  
        [ -x $nginx ] || exit 5  
        [ -f $NGINX_CONF_FILE ] || exit 6  
        echo -n $&quot;Starting $prog: &quot;  
        daemon $nginx -c $NGINX_CONF_FILE  
        retval=$?  
        echo  
        [ $retval -eq 0 ] &amp;amp;&amp;amp; touch $lockfile  
        return $retval  
    }  
      
    stop() {  
        echo -n $&quot;Stopping $prog: &quot;  
        killproc $prog -QUIT  
        retval=$?  
        echo  
        [ $retval -eq 0 ] &amp;amp;&amp;amp; rm -f $lockfile  
        return $retval  
    }  
      
    restart() {  
        configtest || return $?  
        stop  
        start  
    }  
      
    reload() {  
        configtest || return $?  
        echo -n $&quot;Reloading $prog: &quot;  
        killproc $nginx -HUP  
        RETVAL=$?  
        echo  
    }  
      
    force_reload() {  
        restart  
    }  
      
    configtest() {  
      $nginx -t -c $NGINX_CONF_FILE  
    }  
      
    rh_status() {  
        status $prog  
    }  
      
    rh_status_q() {  
        rh_status &amp;gt;/dev/null 2&amp;gt;&amp;amp;1  
    }  
      
    case &quot;$1&quot; in  
        start)  
            rh_status_q &amp;amp;&amp;amp; exit 0  
            $1  
            ;;  
        stop)  
            rh_status_q || exit 0  
            $1  
            ;;  
        restart|configtest)  
            $1  
            ;;  
        reload)  
            rh_status_q || exit 7  
            $1  
            ;;  
        force-reload)  
            force_reload  
            ;;  
        status)  
            rh_status  
            ;;  
        condrestart|try-restart)  
            rh_status_q || exit 0  
                ;;  
        *)  
            echo $&quot;Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}&quot;  
            exit 2  
    esac  
   ###############################################
</pre>
<p>:wq! #保存退出</p>
<p>chmod 775 /etc/rc.d/init.d/nginx #赋予文件执行权限</p>
<p>chkconfig nginx on #设置开机启动<br />
/sbin/chkconfig nginx on<br />
检查一下： sudo /sbin/chkconfig --list nginx<br />
nginx 0:off 1:off 2:on 3:on 4:on 5:on 6:off<br />
完成！ /etc/rc.d/init.d/nginx restart #重启</p>
<p><strong>安装php</strong></p>
<p>cd /usr/local/src</p>
<p>tar -zvxf php-5.3.13.tar.gz</p>
<p>cd php-5.3.13</p>
<p>mkdir -p /usr/local/php5 #建立php安装目录</p>
<p>./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-gd --with-iconv --with-zlib --enable-xml --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl --with-jpeg-dir --with-freetype-dir #配置</p>
<p>make #编译</p>
<p>make install #安装</p>
<p>cp php.ini-production /usr/local/php5/etc/php.ini #复制php配置文件到安装目录</p>
<p>rm -rf /etc/php.ini #删除系统自带配置文件</p>
<p>ln -s /usr/local/php5/etc/php.ini /etc/php.ini #添加软链接</p>
<p>cp /usr/local/php5/etc/php-fpm.conf.default /usr/local/php5/etc/php-fpm.conf #拷贝模板文件为php-fpm配置文件</p>
<p>vi /usr/local/php5/etc/php-fpm.conf #编辑</p>
<p>user = www #设置php-fpm运行账号为www</p>
<p>group = www #设置php-fpm运行组为www</p>
<p>pid = run/php-fpm.pid #取消前面的分号</p>
<p>cp /usr/local/src/php-5.3.13/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm #设置 php-fpm开机启动，拷贝php-fpm到启动目录</p>
<p>chmod +x /etc/rc.d/init.d/php-fpm #添加执行权限</p>
<p>chkconfig php-fpm on #设置开机启动</p>
<p>vi /usr/local/php5/etc/php.ini #编辑配置文件</p>
<p>找到：disable_functions =</p>
<p>修改为：disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname</p>
<p>#列出PHP可以禁用的函数，如果某些程序需要用到这个函数，可以删除，取消禁用。</p>
<p>找到：;date.timezone =</p>
<p>修改为：date.timezone = PRC #设置时区</p>
<p>找到：expose_php = On</p>
<p>修改为：expose_php = OFF #禁止显示php版本的信息</p>
<p>PS：在编译PHP的过程中可能会报UNDEFINED REFERENCE TO `LIBICONV_OPEN 无法编译PHP LIBICONV错误.</p>
<p>配置nginx支持php</p>
<p>vi /usr/local/nginx/conf/nginx.conf #编辑配置文件</p>
<p>user www www; #首行user去掉注释,修改Nginx运行组为www www；必须与/usr/local/php5/etc/php-fpm.conf中的user,group配置相同，否则php运行出错</p>
<p>index index.php index.html index.htm; #添加index.php</p>
<p># pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000</p>
<p>#</p>
<p>location ~ \.php$ {</p>
<p>root html;#此处和server下面root保持一致,默认为html</p>
<p>fastcgi_pass 127.0.0.1:9000;</p>
<p>fastcgi_index index.php;</p>
<p>fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html/$fastcgi_script_name;</p>
<p>include fastcgi_params;</p>
<p>注意：取消FastCGI server部分location的注释,并要注意fastcgi_param行的参数,改为/data/webroot/(此为网站根目录绝对路径)$fastcgi_script_name</p>
<p><strong>/etc/init.d/nginx restart #重启nginx</strong></p>
<p>访问http://ip地址 出现欢迎使用nginx，说明配置成功。默认web目录 /usr/local/nginx/html/可以自己写程序测试PHP是否可用</p>
<p>转载请注明转自:<a href="http://www.yunda51.com">运达's blog</a> 原文地址：<a href="http://www.yunda51.com/1470.html">http://www.yunda51.com/1583.html</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1583</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mysql时间戳转日期以及格式化日期时间</title>
		<link>https://www.yunda51.com/?p=1557</link>
		<comments>https://www.yunda51.com/?p=1557#comments</comments>
		<pubDate>Mon, 01 Jun 2015 01:31:51 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[Mysql]]></category>
		<category><![CDATA[php技术]]></category>
		<category><![CDATA[date_format]]></category>
		<category><![CDATA[from_unixtime]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1557</guid>
		<description><![CDATA[mysql 将时间戳直接转换成日期时间： FROM_UNIXTIME( ):转为时间戳类型时间 UNIX_TI<a href="https://www.yunda51.com/?p=1557" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>mysql 将时间戳直接转换成日期时间：<br />
FROM_UNIXTIME( ):转为时间戳类型时间<br />
UNIX_TIMESTAMP( ) :返回长整形类型时间<br />
from_unixtime()是MySQL里的时间函数<br />
<strong>select  count(id) AS number,from_unixtime(reg_date, '%y-%m-%d') AS time from `gcar_coupon_user`  reg_date GROUP BY time ORDER BY time desc</strong>以上例子是sql语句的例子，直接能将mysql的时间戳类型转换成日期格式</p>
<p>mysql 将日期时间格式化时分秒：<br />
date_format(date,format)<br />
<strong>select  count(nid) AS number,date_format(pub_date, '%y-%m-%d') AS time from `hq_news`  pub_date GROUP BY time ORDER BY time desc</strong><br />
以上例子是，直接能将mysql的日期时间的时分秒给格式化了！</p>
<p>获取当前时间到23:59:59秒时间戳： eco  strtotime($btime=date('Y-m-d'.'23:59:59',time()));<br />
转载请注明转自:<a href="http://www.yunda51.com">运达's blog</a>  原文地址：<a href="http://www.yunda51.com/1557.html">http://www.yunda51.com/1557.html</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1557</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>MySQL动态添删改列字段</title>
		<link>https://www.yunda51.com/?p=1424</link>
		<comments>https://www.yunda51.com/?p=1424#comments</comments>
		<pubDate>Fri, 07 Nov 2014 09:04:18 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[Mysql]]></category>
		<category><![CDATA[php技术]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1424</guid>
		<description><![CDATA[MySQL如何动态添删改列字段呢，SQL如下: 动态增加列字段： ALERT TABLE table1 add<a href="https://www.yunda51.com/?p=1424" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>MySQL如何动态添删改列字段呢，SQL如下:<br />
<strong>动态增加列字段：</strong></p>
<pre class="wp-code-highlight prettyprint">
ALERT TABLE table1 add transactor varchar(10) not Null;
</pre>
<p><strong>动态删除列字段:</strong></p>
<pre class="wp-code-highlight prettyprint">ALERT TABLE TableName drop column field_id;</pre>
<p><strong>动态修改列字段:</strong></p>
<pre class="wp-code-highlight prettyprint">ALERT TABLE table_name change old_field_name  new_field_name field_type;</pre>
<p><strong>动态修改表结构</strong></p>
<pre class="wp-code-highlight prettyprint">ALERT TABLE table_name MODIFY field_name field_type</pre>
<p>转载请注明转自:<a href="http://www.yunda51.com">运达's blog</a>  原文地址：<a href="http://www.yunda51.com/1424.html">http://www.yunda51.com/1424.html</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1424</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>mysql批量替换语句</title>
		<link>https://www.yunda51.com/?p=1267</link>
		<comments>https://www.yunda51.com/?p=1267#comments</comments>
		<pubDate>Mon, 14 Apr 2014 08:05:11 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[php技术]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1267</guid>
		<description><![CDATA[人肉更新是一件非常恐怖的事情. 于是搜了一下使用Mysql批量替换字段的方法! 1. 使用Phpmyadmin<a href="https://www.yunda51.com/?p=1267" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>人肉更新是一件非常恐怖的事情. 于是搜了一下使用Mysql批量替换字段的方法!</p>
<div class="buy shortcodestyle">
1. 使用Phpmyadmin进入数据库管理, 搜索http://wenwen.soso.com, 你就可以看到哪些表里面包含了这个字段.<br />
2. 点击SQL, 执行SQL语句:<br />
<strong>UPDATE ‘表名’ SET ‘字段’ = REPLACE(’字段’,’待替换内容’,’替换值’);</strong><br />
<strong>示例:update `crowd_url_soso` set url=replace(url,'http://wenwen.soso.com/','http://wenwen.sougou.com/');</strong><br />
你可以批量替换任意你想要的字段,这需要看你的要求来了!
</div>
<p>转载请注明转自:<a href="http://www.yunda51.com">运达's blog</a>  原文地址：<a href="http://www.yunda51.com/1267.html">http://www.yunda51.com/1267.html</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1267</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mantis安装步骤</title>
		<link>https://www.yunda51.com/?p=1240</link>
		<comments>https://www.yunda51.com/?p=1240#comments</comments>
		<pubDate>Wed, 26 Mar 2014 07:55:51 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[Mantis]]></category>
		<category><![CDATA[php技术]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[mantis]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[wamp]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1240</guid>
		<description><![CDATA[今天听朋友说的mantis,没事研究了一下,它类似于"禅道",内部使用比较好,它可以指派任务,监视人,任务进展<a href="https://www.yunda51.com/?p=1240" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>今天听朋友说的mantis,没事研究了一下,它类似于"禅道",内部使用比较好,它可以指派任务,监视人,任务进展,任务状态等!在网上搜素了一些资料感觉都太散乱,所以自己总结了一下! 废话就不多说了，安装步骤：<br />
<strong>一、准备工作(windows 平台)</strong><br />
下载Mantis(1.1.8)，地址：http://www.mantisbt.org/download.php<br />
下载EasyPHP（5.2.10），地址：http://www.easyphp.org/download.php(<strong>注:如果你本机有wamp或者Apmserver环境的的就不需要下载Easyphp了,可以把解压之后的mantis文件夹直接仍到www目录下面,然后在mantis文件下找到config_inc.php.sample,复制一份修改成config_inc.php,然后在里面配置一下数据库!<br />
注意:我的配置如下:</strong><br />
        $g_hostname      = "localhost:3306";<br />
  	$g_db_username   = "root";<br />
	$g_db_password   = "";<br />
 	$g_database_name = "bugtracker";<br />
	$g_db_type       = "mysql";<br />
 	# --- email variables -------------<br />
	$g_administrator_email  = 'administrator@example.com';<br />
	$g_webmaster_email      = 'webmaster@example.com';<br />
	# the "From: " field in emails<br />
	$g_from_email           = 'noreply@example.com';<br />
	# the return address for bounced mail<br />
	$g_return_path_email    = 'admin@example.com';<br />
 	$g_default_language                = 'chinese_simplified';)<br />
安装EasyPHP到C:\EasyPHP目录。<br />
把Mantis解压到C:\EasyPHP\www目录下，并重命名为bugs<br />
注意：<br />
1、EasyPHP的版本不要高于5.2.10，原因后面详说。<br />
2、EasyPHP的安装路径中不要包含空格。<br />
3、EasyPHP安装完后不要立即运行它。</p>
<p><strong>二、配置Apache</strong><br />
打开文本文件C:\EasyPHP\conf_files\httpd.conf，<br />
修改Listen 127.0.0.1:80为你想要的IP地址和监听端口，如Listen 192.168.1.103:80。<br />
这个地方IP 地址一定要改成网卡IP，否则用127.0.0.1这样的地址就算是局域网内的其它计算机也无法访问的。<br />
ServerName localhost:80一行视需要修改，方法见该该行上方的参考信息。</p>
<p><strong>三：配置MySQL</strong><br />
安全性：root用户的密码，可视需要自己更改。<br />
字符集：MySQL默认的校验字符集是瑞典语的，需要改成utf8，否则mantins无法存取中文字符。<br />
为防止意外，把MySQL和字符集有关的变量全部改成utf8。<br />
先改character_set_*之类的变量，且是全局的，*_*_ci之类的变量会跟着自己变动（HeidiSQLPortable 工具)。<br />
改完后退出，重新登录MySQL，再查看刚刚修改的变量是否已生效，因为有些(全部？）MySQL全局变量是要从下一个会话才开始生效的，所以不重新登录刷新变量的话会发现变量修改后还是那样。<br />
修改工具可用HeidiSQLPortable、phpmyadmin或MySQL-Front等等，注意这一步要在安装Mantis之前<br />
修改后的字符集变量如下：<br />
<a href="http://www.yunda51.com/wp-content/uploads/2014/03/140326154710.jpg"><img src="http://www.yunda51.com/wp-content/uploads/2014/03/140326154710.jpg" alt="" title="140326154710" width="365" height="214" class="alignnone size-full wp-image-1241" /></a><br />
<strong><br />
四、配置EasyPHP</strong><br />
如果Appache端口配置正确（IP地址有效、端口无冲突）的话还出现下面这个对话框，<br />
<a href="http://www.yunda51.com/wp-content/uploads/2014/03/1546.jpg"><img src="http://www.yunda51.com/wp-content/uploads/2014/03/1546.jpg" alt="" title="1546" width="328" height="109" class="alignnone size-full wp-image-1242" /></a><br />
那么可以配置一下EasyPHP，让它启动时不再验证80端口，步骤如下：<br />
打开配置界面<a href="http://www.yunda51.com/wp-content/uploads/2014/03/16.jpg"><img src="http://www.yunda51.com/wp-content/uploads/2014/03/16.jpg" alt="" title="16" width="430" height="242" class="alignnone size-full wp-image-1243" /></a><br />
把画红色横线部分的勾去掉<br />
<a href="http://www.yunda51.com/wp-content/uploads/2014/03/17.jpg"><img src="http://www.yunda51.com/wp-content/uploads/2014/03/17.jpg" alt="" title="17" width="427" height="243" class="alignnone size-full wp-image-1244" /></a></p>
<p><strong>五、安装、配置Mantis：</strong><br />
启动EasyPHP 5.2.10，打开浏览器，输入http://your-ip:port/bugs<br />
此时应该出现mantis的安装界面，在Admin Username (to create Database) 一行填上root，然后点“Install/Upgrade Database”按钮。接下来的测试和安装界面中没有出现红色背景的测试项，应该就没问题了。</p>
<p>然后打开C:\EasyPHP\www\bugs\config_inc.php，在末尾的“?>”符号之前插入以下语句：<br />
<a href="http://www.yunda51.com/wp-content/uploads/2014/03/18.jpg"><img src="http://www.yunda51.com/wp-content/uploads/2014/03/18.jpg" alt="" title="18" width="457" height="344" class="alignnone size-full wp-image-1245" /></a><br />
修改后以utf8编码的方式“另存为”C:\EasyPHP\www\bugs\config_inc.php，也就是以utf8编码覆盖掉原文件，否则$g_from_name变量中有中文时，邮件发件人部分会显示为乱码，其它部分正常。<br />
邮箱速度：从实际使用的情况来看，$g_phpMailer_method 设为2，用126的smtp作服务器。邮件收取速度如下：gmail邮箱速度很快，马上就可以收到；126的要几到十几分钟上；yahoo.com.cn邮箱半个多小时左右还没收到。<br />
安全性：Mantis要求禁用administrator用户、重命名或删除管理目录admin。注意禁用administrator用户之前先建一个管理员权限的用户。<br />
<strong><br />
六、可能遇到的问题：</strong><br />
如果PHP用5.3及以上版本，有时浏览器上会显示许多以下类似错误：<br />
<a href="http://www.yunda51.com/wp-content/uploads/2014/03/19.jpg"><img src="http://www.yunda51.com/wp-content/uploads/2014/03/19.jpg" alt="" title="19" width="498" height="60" class="alignnone size-full wp-image-1246" /></a><br />
这是因为PHP版本换成5.3以下的就OK了!<br />
转载请注明转自:<a href="http://www.yunda51.com">运达's blog</a>  原文地址：<a href="http://www.yunda51.com/1240.html">http://www.yunda51.com/1240.html</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1240</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>mysql中datetime比较大小问题</title>
		<link>https://www.yunda51.com/?p=1130</link>
		<comments>https://www.yunda51.com/?p=1130#comments</comments>
		<pubDate>Wed, 25 Dec 2013 08:02:53 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[Mysql]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1130</guid>
		<description><![CDATA[mysql中datetime比较大小问题有如下方法： 方法一： 你也可以： select * from cro<a href="https://www.yunda51.com/?p=1130" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>mysql中datetime比较大小问题有如下方法：</p>
<div class="buy shortcodestyle">
<strong>方法一：</strong><br />
你也可以：<br />
select * from crowd_textpage where username='carina' and status=4 and unix_timestamp(inputtime) >= unix_timestamp('2013-12-01') and unix_timestamp(inputtime) <= unix_timestamp('2013-12-20');

delete from crowd_textpage where textname like '合肥%' and time>='2014-03-08' and time<'2014-03-09';

update crowd_textpage set status=2 where status=3 and unix_timestamp(time) >= unix_timestamp('2013-12-28') and unix_timestamp(time) <= unix_timestamp('2013-12-31');///更新把2013-12-28号到2013-12-31状态为3的更新成状态为2!
就是用unix_timestamp函数，将字符型的时间，转成unix时间戳。个人觉得这样比较更踏实点儿。

update `crowd_textpage` set status=2 WHERE STATUS =3 AND url LIKE "%58.com%" AND unix_timestamp( time ) >= unix_timestamp( '2014-03-24' ) AND unix_timestamp( time ) <= unix_timestamp( '2014-03-25' )

<strong>方法二：</strong><br />
time1 between '2013-12-01 17:39:05' and '2013-12-020 17:39:52';</p>
<p><strong>方法三：</strong><br />
可以讲datetime类型转换成date类型再进行比较<br />
例如:convert(date,表名.datetime列名) >= convert(date,表名.datetime列名)</p>
<p>三种方法待求证，总之是不要用字符串这么直接比
</p></div>
<p>转载请注明转自:<a href="http://www.yunda51.com">运达's blog</a>  原文地址：<a href=" http://www.yunda51.com/1130.html"> http://www.yunda51.com/1130.html</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1130</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
