文件php.ini放入windows下,将下面内容拷贝到记事本命名为php.ini放入c:/windows下,重启Apache server:
[PHP]
;;;;;;;;;;;
; WARNING ;
;;;;;;;;;;;
; This is the default settings file for new PHP installations.
; By default, PHP installs itself with a configuration suitable for
; development purposes, and *NOT* for production purposes.
; For several security-oriented considerations that should be taken
; before going online with your site, please consult php.ini-recommended
; and http://php.net/manual/en/security.php.
;;;;;;;;;;;;;;;;;;;
; About php.ini ;
;;;;;;;;;;;;;;;;;;;
; This file controls many aspects of PHP's behavior. In order for PHP to
; read it, it must be named 'php.ini'. PHP looks for it in the current
; working directory, in the path designated by the environment variable
; PHPRC, and in the path that was defined in compile time (in that order).
; Under Windows, the compile-time path is the Windows directory. The
; path in which t ......
文件php.ini放入windows下,将下面内容拷贝到记事本命名为php.ini放入c:/windows下,重启Apache server:
[PHP]
;;;;;;;;;;;
; WARNING ;
;;;;;;;;;;;
; This is the default settings file for new PHP installations.
; By default, PHP installs itself with a configuration suitable for
; development purposes, and *NOT* for production purposes.
; For several security-oriented considerations that should be taken
; before going online with your site, please consult php.ini-recommended
; and http://php.net/manual/en/security.php.
;;;;;;;;;;;;;;;;;;;
; About php.ini ;
;;;;;;;;;;;;;;;;;;;
; This file controls many aspects of PHP's behavior. In order for PHP to
; read it, it must be named 'php.ini'. PHP looks for it in the current
; working directory, in the path designated by the environment variable
; PHPRC, and in the path that was defined in compile time (in that order).
; Under Windows, the compile-time path is the Windows directory. The
; path in which t ......
CENTOS 5的虚拟机,怎么从图形界面切换到命令行界面
1.临时切换:
ctrl+alt+1 …… ctrl+alt+6一共六个控制台。
2.永久关闭图形化:
在root下输入 vi /etc/inittab 将init:5修改为init:3
Mysql rpm包安装,不能重定位(relocatable)
rpm包安装异常,--prefix 参数不能重定位,安装到另一个目录的原因,error: package is not relocatable
[mysql@test922 ~]$ rpm --install --prefix linuxqq-v1.0.2-beta1.i386.rpm
error: linuxqq is not relocatable
经查找,可以使用下面的命令查看rpm包是否可以重定位,也就是安装到另一个目录。
# rpm -qpi linuxqq-v1.0.2-beta1.i386.rpm |head
Name : linuxqq Relocations: (not relocatable)
Version : v1.0.2   ......
CENTOS 5的虚拟机,怎么从图形界面切换到命令行界面
1.临时切换:
ctrl+alt+1 …… ctrl+alt+6一共六个控制台。
2.永久关闭图形化:
在root下输入 vi /etc/inittab 将init:5修改为init:3
Mysql rpm包安装,不能重定位(relocatable)
rpm包安装异常,--prefix 参数不能重定位,安装到另一个目录的原因,error: package is not relocatable
[mysql@test922 ~]$ rpm --install --prefix linuxqq-v1.0.2-beta1.i386.rpm
error: linuxqq is not relocatable
经查找,可以使用下面的命令查看rpm包是否可以重定位,也就是安装到另一个目录。
# rpm -qpi linuxqq-v1.0.2-beta1.i386.rpm |head
Name : linuxqq Relocations: (not relocatable)
Version : v1.0.2   ......
Can't open the mysql.plugin table. Please run mysql_upgrade to create it
当碰到这样的错误是没有初始化mysql数据库,可以运行如下脚本就可以解决
cd /opt/mysql-5.1.46
cd scripts/
./mysql_install_db --user=mysql --datadir=/usr/local/mysql/var/
运行如下的代码就可以解决上述问题 ......
这里收集各种Mysql的基础知识,为了某些场合的需要,还是舍弃navicat之类的工具乖乖用命令行吧
(注意有的命令需要分号有的不需要)
一.基本操作
1.登录
mysql -u 用户名 -p密码 数据库名
这里需要注意的是-u用户名之间可以有空格,而-p密码之间决不能有空格,你可以不填密码,当然用户名你也可以不填,但是会以空的用
户名来登录,然后操作数据库的时候会有很多限制,诸如之类的Access denied for user ''@'localhost' to database错误.
还有,不要在后面加分号;
2.创建用户
grant 权限 on 数据库.* to 用户名@登录主机 identified by "密码";
这里注意的是一定要是最很高权限的用户才可以操作,一般就是root,不嫌麻烦的话也可以直接切入mysql这个数据库把数据添加进
user表里.这里给个例子:grant select,insert,update,delet ......
分页功能的实现是每种WEB开发语言必须要实现的功能。PHP也好,JSP也罢。我准备用两个方法来阐述PHP+MYSQL实现分页的功能。
一、分页程序的原理
分页程序有两个非常重要的参数:每页显示几条记录($pagesize)和当前是第几页($page)。有了这两个参数就可以很方便的写出分页程序,我们以MySql数据库作为数据源,在mysql里如果要想取出表内某段特定内容可以使用的SQL语句:select * from table limit offset,rows来实现。这里的offset是记录偏移量,它的计算方法是offset(下标意思)=$pagesize*($page-1),rows是要显示的记录条数,这里就是$page。也就是说select * from table limit 10,10这条语句的意思是取出表里从第11条记录开始的20条记录。
二、主要代码解析
<?php
$conn=mysql_connect("localhost","root","123");//连接数据库
$rs=mysql_query("select count(*) from tb_product",$conn); //取得记录总数$rs
$pagesize=10; //设置每一页显示的记录数
$myrow = mysql_fetch_array($rs);
$numrows=$myrow[0];
$pages=intval($numrows/$pagesize);//计算总页数
?>
三 完整代码
<html>
<head>
<title> ......
分页功能的实现是每种WEB开发语言必须要实现的功能。PHP也好,JSP也罢。我准备用两个方法来阐述PHP+MYSQL实现分页的功能。
一、分页程序的原理
分页程序有两个非常重要的参数:每页显示几条记录($pagesize)和当前是第几页($page)。有了这两个参数就可以很方便的写出分页程序,我们以MySql数据库作为数据源,在mysql里如果要想取出表内某段特定内容可以使用的SQL语句:select * from table limit offset,rows来实现。这里的offset是记录偏移量,它的计算方法是offset(下标意思)=$pagesize*($page-1),rows是要显示的记录条数,这里就是$page。也就是说select * from table limit 10,10这条语句的意思是取出表里从第11条记录开始的20条记录。
二、主要代码解析
<?php
$conn=mysql_connect("localhost","root","123");//连接数据库
$rs=mysql_query("select count(*) from tb_product",$conn); //取得记录总数$rs
$pagesize=10; //设置每一页显示的记录数
$myrow = mysql_fetch_array($rs);
$numrows=$myrow[0];
$pages=intval($numrows/$pagesize);//计算总页数
?>
三 完整代码
<html>
<head>
<title> ......
在数据库中,UNION和UNION ALL关键字都是将两个结果集合并为一个,但这两者从使用和效率上来说都有所不同。
MySQL中的UNION
UNION在进行表链接后会筛选掉重复的记录,所以在表链接后会对所产生的结果集进行排序运算,删除重复的记录再返回结果。实际大部分应用中是不会产生重复的记录,最常见的是过程表与历史表UNION。如:
select * from gc_dfys union select * from ls_jg_dfys
这个SQL在运行时先取出两个表的结果,再用排序空间进行排序删除重复的记录,最后返回结果集,如果表数据量大的话可能会导致用磁盘进行排序。
MySQL中的UNION ALL
而UNION ALL只是简单的将两个结果合并后就返回。这样,如果返回的两个结果集中有重复的数据,那么返回的结果集就会包含重复的数据了。
从效率上说,UNION ALL 要比UNION快很多,所以,如果可以确认合并的两个结果集中不包含重复的数据的话,那么就使用UNION ALL,如下:
select * from gc_dfys union all select * from ls_jg_dfys
使用Union,则所有返回的行都是唯一的,如同您已经对整个结果集合使用了DISTINCT
使用Union all,则不会排重,返回所有的行
如果您想使用ORDER BY或LIMIT子句来对全部UNIO ......