易截截图软件、单文件、免安装、纯绿色、仅160KB

mysql 备份练习

<?php
$db_name="new";
mysql_connect("localhost","root","123456");
mysql_select_db($db_name);
$tb=mysql_list_tables($db_name);
$sql="";
while($query=mysql_fetch_row($tb)){
 $sql="";$table_sql="";
    $sql.= get_table_fn($query[0]);
    get_table_row($query[0]);
   // echo $table_sql."\n";
}
$f=fopen($db_name.".sql","w+");
fwrite($f,$sql);
fclose($f);
//备份所有表SQL语名
function get_table_fn($db_name){
 $field="CREATE TABLE `$db_name`( \n";
  $query=mysql_query("select * from $db_name");
 while($row=mysql_fetch_field($query)){
   if($row->not_null===1){$null="DEFAULE NULL";}else{$null="NOT NULL";}
   if($row->primary_key===1){$key="primary key";}else{$key="";}
   if($row->unsigned===1){$unsig="unsigned";}else{$unsig="";}
   $field.="`$row->name` $row->type($row->max_length) $null $key $unsig ,\n";
 }
 $field.=")\n";
 return $field;
}
//备份所有表的数剧
function get_table_row($db_name){
     $query=mysql_query("select * from $db_name");
     $field="";
     $num_rows= mysql_num_rows($query);
     $num_field=mysql_num_fields($query);
        $table_sqls="";
  while($row=mysql_fetch_row($query)){
     $r= get_table_fd($num_field,$row);
     $table_sqls.="insert into `$db_name` values($r)\n";
   }
  $f=fopen($db_name.".sql","w+");
  fwrite($f,$table_sqls);
  fclose($f);
}
//获取每张表的字段值
function get_table_fd($num_field,$row){
 $r="";
 for($i=0;$i<$num_field;$i++){
  $r.= "'$row[$i]',";
 }
    $r=substr($r, 0, strlen($r)-1);
    return  $r;
}
?>


相关文档:

Initial Startup of MySQL Cluster


Starting the cluster is not very difficult after it has been configured. Each cluster node process must be started separately, and on the host where it resides. The management node should be started first, followed by the data nodes, and then finally by any SQL nodes:
On the management host, issu ......

How to change max_allowed_packet value in mysql?

 
If you set it in the cnf(it may be my.ini file) you will likely need to restart the server. Optionally, that is a dynamic variable and can be SET GLOBAL or SET SESSION from the command line as well.So just do as follows.
 
mysql>show variables like’max_allowed_packet’; ......

Mysql 基本的常用命令

有很多朋友虽然安装好了 MySQL 但却不知如何使用它。在这篇文章中我们就从连接 MySQL、修改密码、增加用户等方面来学习一些 MySQL 的常用命令。
一、连接MySQL。
格式: mysql -h主机地址 -u用户名 -p用户密码
1、例1:连接到本机上的MYSQL。
  首先在打开 DOS 窗口,然后进入目录 mysql\bin,再键入命令mysql -u ......

mysql cluster rpm安装包的选择 安装 配置 测试

            现在新版本的mysql集群已从普通的mysql版本中提取出来了,也就是要做mysql的集群需要选择mysql集群对应的软件包。而且mysql专门提供了针对redhat 操作系统的rpm软件包。可以从http://dev.mysql.com/downloads/获得对应的操作系统的rpm软件包。在这里主 ......

mysql数据库函数

查询语句:
SELECT 字段名 from 表名.
排序 order by 要排序的字段名 desc :以倒序查询.
limit 从第几个开始 查找多少个 :查找指定个数.
同时查询多个字段用","隔开.
如查询表里面的所有数据在字段名处填"*".
如只想显示某字段的前几位字符可以使用LEFT函数.
SELECT 字段名,LEFT(字段名,位数),字段名 from 表名.
COU ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号