Posts tagged with "mysql"
Tuesday, 24. April 2007, 04:43:17
mysql, php, apache, system
硬盘空间配额 file system quota
我们的server 出了问题, 除了root 用户,可以正常上传文件 ,其它 用户, 包括 apache 都不可以 正常写入文件.写任何文件 都是 0 字节.
好多天来, 重装 apache php mysql ,可以暂时解决 问题,但没过多久问题还是 出来了.
一开始 重装 后 可以用上几天, 现在装完就没用.
这样一天 就过去 也没找到问题.
今天 用某用户 vi 写一文件 报错了
E514: write error (file system full?)
找到 一篇 说
...turns out I went over my quota on the server...
kevin 说空间配额 问题?
df 查一下
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 2016016 1937348 0 100% /
none 1037212 0 1037212 0% /dev/shm
/dev/sda5 70880216 1750920 65528732 3% /usr
/dev/sda3 2016044 163708 1749924 9% /var
my god. 我们的网站放在 /home 下的.空间全用光了.
文件 当然写不进去了.
Thursday, 29. March 2007, 10:14:35
php, mysql
用了 rand() 并且要 分页.
Select * From table order by rand() Limit 10
问题是 分页一下,就会 重新对全部记录随机 一次.
若为 rand(100) 加上基数
则 Limit 不会 重新随机..
Select * From table order by rand($r) Limit 10,10
Thursday, 25. January 2007, 10:37:53
mysql
查找 email中是以 name为头和doname的记录
select * ,CONCAT('%',name,'%') from a where email like CONCAT('%',name,'@',name,'%')
表 A:
name email
admin admin@admin.cn
admin fsdrer
Friday, 10. November 2006, 06:36:10
system, mysql
I also had this problem and fixed it by deleting BOTH my DATA and LOG files at the same time and restarting the server.
For example,
Step 1. Stop MySQL service
Step 2. Delete files:
C:\Program Files\MySQL\MySQL Server 5.0\data\ib_logfile*
C:\MySQL Datafiles\ibdata*
Step 3: Restart MySQL service
MySQL InnoDB needs to create both DATA and LOGS at the same time -- it says this in the log file output. So if you don't delete both data and log files at the same time when it starts up it will fail to create the InnoDB database files properly and InnoDB will show up as DISABLED rather than DEFAULT (when using "show engines").
########################################
From mysql.com
Tuesday, 7. November 2006, 02:16:55
mysql
mysql 的有用工具
http://www.mysql.com/products/tools/数据库转换工具
MySQL Migration Toolkit
客户端
SQLyog
Saturday, 29. April 2006, 07:48:08
Programming, 只言片语, mysql
前晚调试一段php代码,
图片显示不正确.
php没有错,用zend studio,找不出来错.
js代码我用firefox,opera,ie怎么也都找不到错.
几个小时后,我发现有个地方顺序倒了.
就是一个很小很小的错,花了我数个小时.
令狐大哥说的对,应该"对已有的代码给予足够的尊重",
因为 每一段正确的代码都来之不易(或者是能正确执行的代码).
============================
今天 MYSQL5中文乱码
以下是找到的解决方案
---------------------
/*
$sql = "SET collation_connection = 'gb2312_chinese_ci'";
$Data->Execute($sql);
*/
$sql = "SET CHARACTER SET utf8";
$Data->Execute($sql);
----------------------
我在
mysql_query('...');
前加上
mysql_query( "SET CHARACTER SET utf8");
因为mysql 的default character set is: latin1 ;
用
mysql_client_encoding();
可得此结果.
ConvertZ 批量转码
ConvertZ
对文件内码进行批量转换 Big5/GBK/Unicode/UTF8 ...
当要转换成UTF-8时,需要设置“转码设定->加BOM到UTF-8档案”。
pics表中有多个行对应 products 中的一行,
而却只要一行。
SELECT DISTINCT products.id, products.code, products.name, pics.url
FROM products
LEFT JOIN pics ON ( products.id = pics.article_id )
WHERE products.menu_id = '18'
GROUP BY products.id
Saturday, 29. April 2006, 07:46:30
Programming, mysql
MySQL 的字符集支持(Character Set Support)有两个方面:字符集(Character set)和排序方式(Collation)。对于字符集的支持细化到四个层次: 服务器(server),数据库(database),数据表(table)和连接(connection)。
查看系统的字符集和排序方式的设定可以通过下面的两条命令:
mysql> SHOW VARIABLES LIKE 'character_set_%';
+--------------------------+-------------------------------+
| Variable_name | Value |
+--------------------------+-------------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | D:\var\mysql5\share\charsets\ |
+--------------------------+-------------------------------+
mysql> SHOW VARIABLES LIKE 'collation_%';
+----------------------+-------------------+
| Variable_name | Value |
+----------------------+-------------------+
| collation_connection | latin1_swedish_ci |
| collation_database | latin1_swedish_ci |
| collation_server | latin1_swedish_ci |
+----------------------+-------------------+
SET CHARACTER SET 'utf8';
相当于:
SET character_set_client = utf8;
SET character_set_results = utf8;
但执行"INSERT"语句时,仍然乱码;
SET NAMES 'utf8';
它相当于下面的三句指令:
SET character_set_client = utf8;
SET character_set_results = utf8;
SET character_set_connection = utf8;
Saturday, 29. April 2006, 07:44:12
Programming, mysql
表A有两个字段name跟id,id为int类型但不是auto_increment ,并且可以有相同值.
现在要将所有id=14的记录的name值后面加一个字符$i,而$i是按顺序从1到select * from A where id=14所有的记录数的一个值,即:
$result=mysql_query("select * from A where id=14");
$a=mysql_num_rows($result);
for ($i=1;$i<=$a;$i++ )
此SQL语句如何写?
================================
SET @t :=0;
UPDATE `a` SET
`id` = IF ((@t := @t +1),`id` ,`id` ),
`name` = CONCAT(`name` , @t)
where `id`=14
#设用户变量@t
#用户变量@t 自加
#将`name` 原名与@t 字符串连接
#over
我的test SQL DB
-- 表的结构 `a`
CREATE TABLE `a` (
`id` int(11) NOT NULL default '0',
`name` char(50) default NULL
) TYPE=MyISAM;
INSERT INTO `a` VALUES (1, 'A11');
INSERT INTO `a` VALUES (2, 'A12');
INSERT INTO `a` VALUES (3, 'A13');
INSERT INTO `a` VALUES (14, '141');
INSERT INTO `a` VALUES (14, '252');
INSERT INTO `a` VALUES (14, '363');
INSERT INTO `a` VALUES (14, '474');
Saturday, 29. April 2006, 07:42:36
Programming, mysql, php
按http://www.phpx.com/pth104882.php 这的思路写出ip地址信息查询
这是有个文本的ip地址信息有22万多条记录,格式为(ip_start,ip_end,location); 为了最简单高效的查询,怎么样设计mysql的表。
给出的答案是用一个表 ip(ip_end (bigint),location (varchar)) 在ip_end做索引;
实现要点如下:
先新建表 ip(ip_start,ip_end,location);将文本数据导入这个表中。
再将ip_start删除.
1.查询ip地址时,SELECT location FROM ip WHERE ip_end >=$tip LIMIT 0,1
只能用ip_end因为若用ip_start那应该是 ip_start <= $tip 这样只能返回表头的第一个记录,而不是我们要的记录;
用LIMIT 0,1 使从表头开始开始,只返回一个条符合条件的记录。
2.ip的转换,php中有ip2long函数可以直接把string 型的ip地址变为一个长整型,但到2xx,xxx,xxx,xxx时返回负值。这样无法插入表中。自定义转换函数如下:
function iptoint($ip)
{
$ip = explode(".",$ip);
if (!is_numeric(join(NULL,$ip)) or count($ip) != 4) {
return false;
} else {
return ($ip[3]+256*$ip[2]+65536*$ip[1]+16777216*$ip[0]);
}
}