﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>IT博客-peakway-文章分类-php</title><link>http://www.cnitblog.com/peak/category/1159.html</link><description>奋斗不止，走向成功！</description><language>zh-cn</language><lastBuildDate>Wed, 28 Sep 2011 08:45:43 GMT</lastBuildDate><pubDate>Wed, 28 Sep 2011 08:45:43 GMT</pubDate><ttl>60</ttl><item><title>MySQL 常用命令</title><link>http://www.cnitblog.com/peak/articles/3826.html</link><dc:creator>peakway</dc:creator><author>peakway</author><pubDate>Thu, 03 Nov 2005 02:19:00 GMT</pubDate><guid>http://www.cnitblog.com/peak/articles/3826.html</guid><wfw:comment>http://www.cnitblog.com/peak/comments/3826.html</wfw:comment><comments>http://www.cnitblog.com/peak/articles/3826.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/peak/comments/commentRss/3826.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/peak/services/trackbacks/3826.html</trackback:ping><description><![CDATA[<P>　　有很多朋友虽然安装好了 MySQL 但却不知如何使用它。在这篇文章中我们就从连接 MySQL、修改密码、增加用户等方面来学习一些 MySQL 的常用命令。 </P>
<P><STRONG>一、连接MySQL。</STRONG> </P>
<P>格式： mysql -h主机地址 -u用户名 －p用户密码 </P>
<P>1、例1：连接到本机上的MYSQL。 </P>
<P>　　首先在打开 DOS 窗口，然后进入目录 mysql\bin，再键入命令mysql -uroot -p，回车后提示你输密码，如果刚安装好 MySQL，超级用户 root 是没有密码的，故直接回车即可进入到 MySQL 中了，MySQL 的提示符是：<FONT face="Courier New">mysql&gt;</FONT> </P>
<P>2、例2：连接到远程主机上的 MySQL。</P>
<P>　　假设远程主机的IP为：110.110.110.110，用户名为root，密码为abcd123。则键入以下命令： </P>
<P><FONT face="Courier New">mysql -h110.110.110.110 -uroot -pabcd123</FONT> </P>
<P>（注:u与root可以不用加空格，其它也一样） </P>
<P>3、退出 MySQL 命令： exit （回车） </P>
<P><STRONG>二、修改密码。</STRONG> </P>
<P>格式：mysqladmin -u用户名 -p旧密码 password 新密码 </P>
<P>1、例1：给root加个密码ab12。首先在DOS下进入目录mysqlbin，然后键入以下命令 </P>
<P><FONT face="Courier New">mysqladmin -uroot -password ab12</FONT> </P>
<P>注：因为开始时root没有密码，所以-p旧密码一项就可以省略了。 </P>
<P>2、例2：再将root的密码改为djg345。 </P>
<P><FONT face="Courier New">mysqladmin -uroot -pab12 password djg345</FONT> </P>
<P><STRONG>三、增加新用户。</STRONG></P>
<P>（注意：和上面不同，下面的因为是 MySQL 环境中的命令，所以后面都带一个分号作为命令结束符） </P>
<P>格式：grant select on 数据库.* to 用户名@登录主机 identified by "密码" </P>
<P>例1、增加一个用户 test1 密码为 abc，让他可以在任何主机上登录，并对所有数据库有查询、插入、修改、删除的权限。首先用以 root 用户连入 MySQL，然后键入以下命令： </P>
<P><FONT face="Courier New">grant select, insert, update, delete on *.* to </FONT><FONT face="Courier New">test1@"%</FONT><FONT face="Courier New">" Identified by "abc";</FONT> </P>
<P>但例1增加的用户是十分危险的，你想如某个人知道test1的密码，那么他就可以在internet上的任何一台电脑上登录你的mysql数据库并对你的数据可以为所欲为了，解决办法见例2。 </P>
<P>例2、增加一个用户test2密码为abc,让他只可以在localhost上登录，并可以对数据库 mydb进行查询、插入、修改、删除的操作（localhost指本地主机，即MYSQL数据库所在的那台主机），这样用户即使用知道test2的密码，他也无法从internet上直接访问数据库，只能通过MYSQL主机上的web页来访问了。 </P>
<P><FONT face="Courier New">grant select, insert, update,delete on mydb.* to </FONT><FONT face="Courier New">test2@localhost</FONT><FONT face="Courier New"> identified by "abc";</FONT> </P>
<P>　　如果你不想test2有密码，可以再打一个命令将密码消掉。 </P>
<P><FONT face="Courier New">grant select, insert, update, delete on mydb.* to test2@localhost identified by "";</FONT> </P>
<P>　　在上篇我们讲了登录、增加用户、密码更改等问题。下篇我们来看看MYSQL中有关数据库方面的操作。注意：你必须首先登录到MYSQL中，以下操作都是在MYSQL的提示符下进行的，而且每个命令以分号结束。 </P>
<P><STRONG>一、操作技巧</STRONG> </P>
<P>1、如果你打命令时，回车后发现忘记加分号，你无须重打一遍命令，只要打个分号回车就可以了。也就是说你可以把一个完整的命令分成几行来打，完后用分号作结束标志就OK。 </P>
<P>2、你可以使用光标上下键调出以前的命令。但以前我用过的一个MYSQL旧版本不支持。我现在用的是mysql-3.23.27-beta-win。 </P>
<P><STRONG>二、显示命令</STRONG> </P>
<P>1、显示数据库列表。 </P>
<P><FONT face="Courier New">show databases;</FONT> </P>
<P>　　刚开始时才两个数据库：mysql 和 test。mysql 库很重要它里面有 MySQL 的系统信息，我们改密码和新增用户，实际上就是用这个库进行操作。 </P>
<P>2、显示库中的数据表： </P>
<P><FONT face="Courier New">use mysql; //打开库，学过 FOXBASE 的一定不会陌生吧</FONT> </P>
<P><FONT face="Courier New">show tables;</FONT> </P>
<P>3、显示数据表的结构： </P>
<P><FONT face="Courier New">describe 表名;</FONT> </P>
<P>4、建库： </P>
<P><FONT face="Courier New">create database 库名;</FONT> </P>
<P>5、建表： </P>
<P><FONT face="Courier New">use 库名;</FONT></P>
<P><FONT face="Courier New">create table 表名 (字段设定列表);</FONT></P>
<P>6、删库和删表: </P>
<P><FONT face="Courier New">drop database 库名; </FONT></P>
<P><FONT face="Courier New">drop table 表名;</FONT></P>
<P>7、将表中记录清空： </P>
<P><FONT face="Courier New">delete from 表名;</FONT> </P>
<P>8、显示表中的记录： </P>
<P><FONT face="Courier New">select * from 表名;</FONT> </P>
<P><STRONG>三、一个建库和建表以及插入数据的实例</STRONG> </P>
<P><FONT face="Courier New">drop database if exists school; //如果存在SCHOOL则删除 <BR>create database school; //建立库SCHOOL <BR>use school; //打开库SCHOOL <BR>create table teacher //建立表TEACHER <BR>( <BR>&nbsp;&nbsp;&nbsp; id int(3) auto_increment not null primary key, <BR>&nbsp;&nbsp;&nbsp; name char(10) not null, <BR>&nbsp;&nbsp;&nbsp; address varchar(50) default '深圳', <BR>&nbsp;&nbsp;&nbsp; year date <BR>); //建表结束 </FONT></P>
<P><FONT face="Courier New">//以下为插入字段 <BR>insert into teacher values('','glchengang','深圳一中','1976-10-10'); <BR>insert into teacher values('','jack','深圳一中','1975-12-23');</FONT> </P>
<P>　　注：在建表中（1）将 ID 设为长度为 3 的数字字段 int(3) 并让它每个记录自动加一，auto_increment 并不能为空 not null 而且让他成为主字段 primary key（2）将 NAME 设为长度为 10 的字符字段（3）将 ADDRESS 设为长度 50 的字符字段，而且缺省值为深圳。varchar 和char 有什么区别呢，只有等以后的文章再说了。（4）将 YEAR 设为日期字段。 </P>
<P>　　如果你在 MySQL 提示符键入上面的命令也可以，但不方便调试。你可以将以上命令原样写入一个文本文件中假设为 school.sql，然后复制到 c:\ 下，并在 DOS 状态进入目录 \mysql\bin\ ，然后键入以下命令： </P>
<P><FONT face="Courier New">mysql -uroot -p密码 &lt; c:\school.sql </FONT></P>
<P>　　如果成功，空出一行无任何显示；如有错误，会有提示。（以上命令已经调试，你只要将//的注释去掉即可使用）。 </P>
<P><STRONG>四、将文本数据转到数据库中</STRONG> </P>
<P>1、文本数据应符合的格式：字段数据之间用 tab 键隔开，null 值用 \n 来代替. </P>
<P>例： </P>
<P>3 rose 深圳二中 1976-10-10 </P>
<P>4 mike 深圳一中 1975-12-23 </P>
<P>2、数据传入命令</P>
<P><FONT face="Courier New">load data local infile "文件名" into table 表名;</FONT> </P>
<P>　　注意：你最好将文件复制到 \mysql\bin 目录下，并且要先用 use 命令打表所在的库。 </P>
<P><STRONG>五、备份数据库：</STRONG> （命令在DOS的 \mysql\bin 目录下执行） </P>
<P><FONT face="Courier New">mysqldump --opt school&gt;school.bbb</FONT> </P>
<P>　　注释：将数据库 school 备份到 school.bbb 文件，school.bbb 是一个文本文件，文件名任取，打开看看你会有新发现。 </P>
<P>　　后记：其实 MySQL 的对数据库的操作与其它的 SQL 类数据库大同小异，您最好找本将 SQL 的书看看。我在这里只介绍一些基本的，其实我也就只懂这些了，呵呵。最好的MYSQL教程还是"晏子"译的"MYSQL中文参考手册"不仅免费每个相关网站都有下载，而且它是最权威的。可惜不是象"PHP4中文手册"那样是chm的格式，在查找函数命令的时候不太方便。</P><img src ="http://www.cnitblog.com/peak/aggbug/3826.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/peak/" target="_blank">peakway</a> 2005-11-03 10:19 <a href="http://www.cnitblog.com/peak/articles/3826.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>PHP开发框架总结</title><link>http://www.cnitblog.com/peak/articles/3792.html</link><dc:creator>peakway</dc:creator><author>peakway</author><pubDate>Wed, 02 Nov 2005 02:51:00 GMT</pubDate><guid>http://www.cnitblog.com/peak/articles/3792.html</guid><wfw:comment>http://www.cnitblog.com/peak/comments/3792.html</wfw:comment><comments>http://www.cnitblog.com/peak/articles/3792.html#Feedback</comments><slash:comments>13</slash:comments><wfw:commentRss>http://www.cnitblog.com/peak/comments/commentRss/3792.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/peak/services/trackbacks/3792.html</trackback:ping><description><![CDATA[<P>收集整理了一些主要的PHP开发框架和CMS系统平台，在此一并作个总结，或许以后会有补充。</P>
<P>开发框架<BR>WACT <A href="http://wact.sourceforge.net/">http://wact.sourceforge.net/</A><BR>老牌的PHP编程框架，实现了很多企业级的开发模式</P>
<P>Horde <A href="http://www.horde.org/horde/">http://www.horde.org/horde/</A><BR>提供了一些常用类库，可以满足参数处理、数据压缩、浏览器检测、链接跟踪以及 MIME。需要PEAR类库的支持，提供了API参考。</P>
<P>Seagull <A href="http://seagull.phpkitchen.com/">http://seagull.phpkitchen.com/</A><BR>一个面向对象的PHP开发框架，使用了Pear类库，其主要特性有：运用组件方式、简化数据访问、错误处理机制和权限认证管理等。</P>
<P>studs <A href="http://mojavelinux.com/projects/studs/">http://mojavelinux.com/projects/studs/</A><BR>Jakarta Struts结构移植过来的PHP开发框架，使用面向对象的开发结构和API，模拟了一个HTTP Servlet容器<BR>和使用了PHP服务页面引擎技术</P>
<P>InterJinn <A href="http://www.interjinn.com/">http://www.interjinn.com/</A><BR>有很多扩展模块提供下载，可惜配置文件使用的是inc格式</P>
<P>Php.MVC <A href="http://www.phpmvc.net/">http://www.phpmvc.net/</A><BR>知名的PHP开发框架 ，基于Java的Struts</P>
<P>Phrame <A href="http://phrame.sourceforge.net/">http://phrame.sourceforge.net/</A><BR>虽然不大，但用的很多，也是基于Struts思想</P>
<P>Ambivalence <A href="http://amb.sourceforge.net/">http://amb.sourceforge.net/</A><BR>基于Maverick思想实现的PHP开发框架</P>
<P>binarycloud <A href="http://www.binarycloud.com/">http://www.binarycloud.com/</A><BR>使用了Smarty模板引擎，文档很完善</P>
<P>Prado <A href="http://www.xisc.com/">http://www.xisc.com/</A><BR>Zend获奖作品，基于事件驱动的PHP开发框架</P>
<P>rwfphp <A href="http://www.rwfphp.org/">http://www.rwfphp.org/</A><BR>面向对象和事件驱动的php开发框架</P>
<P>Krysalis <A href="http://www.kompletecms.com/">http://www.kompletecms.com/</A><BR>把XML文档转换为XHTML文档的PHP系统</P>
<P>FastFrame <A href="http://codejanitor.com/wp/apps/fastframe/">http://codejanitor.com/wp/apps/fastframe/</A><BR>可以快速地实现表单提交</P>
<P>Blueshoes <A href="http://www.blueshoes.net/">http://www.blueshoes.net/</A><BR>比较先进的一个framework，提供了很多GUI组件</P>
<P>下面这些我也没有详细看<BR>Cgiapp <A href="http://weierophinney.net/matthew/download">http://weierophinney.net/matthew/download</A><BR>Fuselogic <A href="http://www.haltebis.com/index/wakka/main/FuseLogic">http://www.haltebis.com/index/wakka/main/FuseLogic</A><BR>Copix <A href="http://copix.aston.fr/">http://copix.aston.fr/</A><BR>logicreate <A href="http://www.logicreate.com/">http://www.logicreate.com/</A><BR>booby <A href="http://www.nauta.be/booby/">http://www.nauta.be/booby/</A> </P>
<P>主要的CMS系统<BR>Drupal <A href="http://www.drupal.org/">http://www.drupal.org/</A><BR>Mambo <A href="http://www.mamboportal.com/">http://www.mamboportal.com/</A><BR>Nucleus <A href="http://nucleuscms.org/">http://nucleuscms.org/</A><BR>Midgard <A href="http://www.midgard-project.org/">http://www.midgard-project.org/</A><BR>Pmachine <A href="http://www.pmachine.com/">http://www.pmachine.com/</A><BR>PostNuke <A href="http://www.post-nuke.net/">http://www.post-nuke.net/</A><BR>sitellite <A href="http://www.sitellite.org/">http://www.sitellite.org/</A> <BR>eZPublish <A href="http://ez.no/">http://ez.no/</A><BR>limb <A href="http://limb-project.com/">http://limb-project.com/</A> <BR></P><img src ="http://www.cnitblog.com/peak/aggbug/3792.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/peak/" target="_blank">peakway</a> 2005-11-02 10:51 <a href="http://www.cnitblog.com/peak/articles/3792.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>