⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 server-cfg

📁 开启mysql的远程连接的方法 mysql-noinstall-5.1.6-alpha-win32.zip
💻
📖 第 1 页 / 共 5 页
字号:
}##############################################################################	     Configuration for Access#############################################################################package db_access;sub new{  my ($type,$host,$database)= @_;  my $self= {};  my %limits;  bless $self;  $self->{'cmp_name'}		= "access";  $self->{'data_source'}	= "DBI:ODBC:$database";  if (defined($host) && $host ne "")  {    $self->{'data_source'}	.= ":$host";  }  $self->{'limits'}		= \%limits;  $self->{'blob'}		= "blob";  $self->{'text'}		= "blob"; # text ?   $self->{'double_quotes'}	= 1; # Can handle:  'Walker''s'  $self->{'drop_attr'}		= "";  $self->{'transactions'}	= 1; # Transactions enabled  $limits{'max_conditions'}	= 97; # We get 'Query is too complex'  $limits{'max_columns'}	= 255;	# Max number of columns in table  $limits{'max_tables'}		= 65000;	# Should be big enough  $limits{'max_text_size'}	= 255;  # Max size with default buffers.  $limits{'query_size'}		= 65535; # Not a limit, big enough  $limits{'max_index'}		= 32; # Max number of keys  $limits{'max_index_parts'}	= 10; # Max segments/key  $limits{'max_column_name'}	= 64; # max table and column name  $limits{'join_optimizer'}	= 1; # Can optimize FROM tables  $limits{'load_data_infile'}	= 0; # Has load data infile  $limits{'lock_tables'}	= 0; # Has lock tables  $limits{'functions'}		= 1; # Has simple functions (+/-)  $limits{'group_functions'}	= 1; # Have group functions  $limits{'group_func_sql_min_str'}	= 1; # Can execute MIN() and MAX() on strings  $limits{'group_distinct_functions'}= 0; # Have count(distinct)  $limits{'select_without_from'}= 1; # Can do 'select 1';  $limits{'multi_drop'}		= 0; # Drop table can take many tables  $limits{'subqueries'}		= 1; # Supports sub-queries.  $limits{'left_outer_join'}	= 1; # Supports left outer joins  $limits{'table_wildcard'}	= 1; # Has SELECT table_name.*  $limits{'having_with_alias'}  = 0; # Can use aliases in HAVING  $limits{'having_with_group'}	= 1; # Can use group functions in HAVING  $limits{'like_with_column'}	= 1; # Can use column1 LIKE column2  $limits{'order_by_position'}  = 1; # Can use 'ORDER BY 1'  $limits{'group_by_position'}  = 0; # Can use 'GROUP BY 1'  $limits{'alter_table'}	= 1;  $limits{'alter_add_multi_col'}= 2; #Have ALTER TABLE t add a int, b int;  $limits{'alter_table_dropcol'}= 1;  $limits{'group_func_extra_std'} = 0; # Have group function std().  $limits{'func_odbc_mod'}	= 0; # Have function mod.  $limits{'func_extra_%'}	= 0; # Has % as alias for mod()  $limits{'func_odbc_floor'}	= 0; # Has func_odbc_floor function  $limits{'func_extra_if'}	= 0; # Have function if.  $limits{'column_alias'}	= 1; # Alias for fields in select statement.  $limits{'NEG'}		= 1; # Supports -id  $limits{'func_extra_in_num'}	= 1; # Has function in  $limits{'unique_index'}	= 1; # Unique index works or not  $limits{'insert_select'}	= 1;  $limits{'working_blobs'}	= 1; # If big varchar/blobs works  $limits{'order_by_unused'}	= 1;  $limits{'working_all_fields'} = 1;  $limits{'multi_distinct'}     = 1; # allows select count(distinct a),count(distinct b)..   return $self;}## Get the version number of the database#sub version{  my ($self)=@_;  my $version="Access 2000";  $version .= "/ODBC" if ($self->{'data_source'} =~ /:ODBC:/);  return $version;		#DBI/ODBC can't return the server version}sub connect{  my ($self)=@_;  my ($dbh);  $dbh=DBI->connect($self->{'data_source'}, $main::opt_user,		    $main::opt_password,{ PrintError => 0}) ||		      die "Got error: '$DBI::errstr' when connecting to " . $self->{'data_source'} ." with user: '$main::opt_user' password: '$main::opt_password'\n";  return $dbh;}## Returns a list of statements to create a table# The field types are in ANSI SQL format.#sub create{  my($self,$table_name,$fields,$index) = @_;  my($query,@queries,$nr);  $query="create table $table_name (";  foreach $field (@$fields)  {    $field =~ s/mediumint/integer/i;    $field =~ s/tinyint/smallint/i;    $field =~ s/float\(\d+,\d+\)/float/i;    $field =~ s/integer\(\d+\)/integer/i;    $field =~ s/smallint\(\d+\)/smallint/i;    $field =~ s/int\(\d+\)/integer/i;    $field =~ s/blob/text/i;    $query.= $field . ',';  }  substr($query,-1)=")";		# Remove last ',';  push(@queries,$query);  $nr=0;  foreach $index (@$index)  {    $ext="WITH DISALLOW NULL";    if (($index =~ s/primary key/unique index primary_key/i))    {      $ext="WITH PRIMARY;"    }    if ($index =~ /^unique.*\(([^\(]*)\)$/i)    {      $nr++;      $index="unique index ${table_name}_$nr ($1)";    }    $index =~ /^(.*)\s+(\(.*\))$/;    push(@queries,"create ${1} on $table_name $2");  }  return @queries;}## Do any conversions to the ANSI SQL query so that the database can handle it#sub query {  my($self,$sql) = @_;  return $sql;}sub drop_index{  my ($self,$table,$index) = @_;  return "DROP INDEX $index ON $table";}## Abort if the server has crashed# return: 0 if ok#	  1 question should be retried#sub abort_if_fatal_error{  return 1 if (($DBI::errstr =~ /The database engine couldn\'t lock table/i) ||               ($DBI::errstr =~ /niet vergrendelen. De tabel is momenteel in gebruik /i) ||	       ($DBI::errstr =~ /Den anv.* redan av en annan/i) ||	       ($DBI::errstr =~ /non-exclusive access/));  return 0;}sub small_rollback_segment{  return 0;}sub reconnect_on_errors{  return 1;}sub fix_for_insert{  my ($self,$cmd) = @_;  return $cmd;}##############################################################################	     Configuration for Microsoft SQL server#############################################################################package db_ms_sql;sub new{  my ($type,$host,$database)= @_;  my $self= {};  my %limits;  bless $self;  $self->{'cmp_name'}		= "ms-sql";  $self->{'data_source'}	= "DBI:ODBC:$database";  if (defined($host) && $host ne "")  {    $self->{'data_source'}	.= ":$host";  }  $self->{'limits'}		= \%limits;  $self->{'blob'}		= "text";  $self->{'text'}		= "text";  $self->{'double_quotes'}	= 1; # Can handle:  'Walker''s'  $self->{'drop_attr'}		= "";  $self->{'transactions'}	= 1; # Transactions enabled  $limits{'max_conditions'}	= 1030; # We get 'Query is too complex'  $limits{'max_columns'}	= 250;	# Max number of columns in table  $limits{'max_tables'}		= 65000;	# Should be big enough  $limits{'max_text_size'}	= 9830;  # Max size with default buffers.  $limits{'query_size'}		= 9830; # Max size with default buffers.  $limits{'max_index'}		= 64; # Max number of keys  $limits{'max_index_parts'}	= 15; # Max segments/key  $limits{'max_column_name'}	= 30; # max table and column name  $limits{'join_optimizer'}	= 1; # Can optimize FROM tables  $limits{'load_data_infile'}	= 0; # Has load data infile  $limits{'lock_tables'}	= 0; # Has lock tables  $limits{'functions'}		= 1; # Has simple functions (+/-)  $limits{'group_functions'}	= 1; # Have group functions  $limits{'group_func_sql_min_str'}	= 1; # Can execute MIN() and MAX() on strings  $limits{'group_distinct_functions'}= 1; # Have count(distinct)  $limits{'select_without_from'}= 1; # Can do 'select 1';  $limits{'multi_drop'}		= 1; # Drop table can take many tables  $limits{'subqueries'}		= 1; # Supports sub-queries.  $limits{'left_outer_join'}	= 1; # Supports left outer joins  $limits{'table_wildcard'}	= 1; # Has SELECT table_name.*  $limits{'having_with_alias'}  = 0; # Can use aliases in HAVING  $limits{'having_with_group'}	= 1; # Can't use group functions in HAVING  $limits{'like_with_column'}	= 1; # Can use column1 LIKE column2  $limits{'order_by_position'}  = 1; # Can use 'ORDER BY 1'  $limits{'group_by_position'}  = 0; # Can use 'GROUP BY 1'  $limits{'alter_table'}	= 1;  $limits{'alter_add_multi_col'}= 0;  $limits{'alter_table_dropcol'}= 0;  $limits{'group_func_extra_std'} = 0; # Have group function std().  $limits{'func_odbc_mod'}	= 0; # Have function mod.  $limits{'func_extra_%'}	= 1; # Has % as alias for mod()  $limits{'func_odbc_floor'}	= 1; # Has func_odbc_floor function  $limits{'func_extra_if'}	= 0; # Have function if.  $limits{'column_alias'}	= 1; # Alias for fields in select statement.  $limits{'NEG'}		= 1; # Supports -id  $limits{'func_extra_in_num'}	= 0; # Has function in  $limits{'unique_index'}	= 1; # Unique index works or not  $limits{'insert_select'}	= 1;  $limits{'working_blobs'}	= 1; # If big varchar/blobs works  $limits{'order_by_unused'}	= 1;  $limits{'working_all_fields'} = 1;  $limits{'multi_distinct'}     = 1; # allows select count(distinct a),count(distinct b)..   return $self;}## Get the version number of the database#sub version{  my ($self)=@_;  my($sth,@row, $version);  $version='MS SQL server ?';  $dbh=$self->connect();  $sth = $dbh->prepare("SELECT \@\@VERSION") or die $DBI::errstr;  $sth->execute or die $DBI::errstr;  @row = $sth->fetchrow_array;  if ($row[0]) {     @server = split(/\n/,$row[0]);     chomp(@server);     $version= "$server[0]";  }   $sth->finish;  $version .= "/ODBC" if ($self->{'data_source'} =~ /:ODBC:/);  return $version;}sub connect{  my ($self)=@_;  my ($dbh);  $dbh=DBI->connect($self->{'data_source'}, $main::opt_user,		    $main::opt_password,{ PrintError => 0}) ||		      die "Got error: '$DBI::errstr' when connecting to " . $self->{'data_source'} ." with user: '$main::opt_user' password: '$main::opt_password'\n";  return $dbh;}## Returns a list of statements to create a table# The field types are in ANSI SQL format.#sub create{  my($self,$table_name,$fields,$index) = @_;  my($query,@queries,$nr);  $query="create table $table_name (";  foreach $field (@$fields)  {    $field =~ s/mediumint/integer/i;    $field =~ s/float\(\d+,\d+\)/float/i;    $field =~ s/double\(\d+,\d+\)/float/i;    $field =~ s/double/float/i;    $field =~ s/integer\(\d+\)/integer/i;    $field =~ s/int\(\d+\)/integer/i;    $field =~ s/smallint\(\d+\)/smallint/i;    $field =~ s/smallinteger/smallint/i;    $field =~ s/tinyint\(\d+\)/tinyint/i;    $field =~ s/tinyinteger/tinyint/i;    $field =~ s/blob/text/i;    $query.= $field . ',';  }  substr($query,-1)=")";		# Remove last ',';  push(@queries,$query);  $nr=0;  foreach $index (@$index)  {    $ext="WITH DISALLOW NULL";    if (($index =~ s/primary key/unique index primary_key/i))    {      $ext="WITH PRIMARY;"    }    if ($index =~ /^unique.*\(([^\(]*)\)$/i)    {      $nr++;      $index="unique index ${table_name}_$nr ($1)";    }    $index =~ /^(.*)\s+(\(.*\))$/;    push(@queries,"create ${1} on $table_name $2");  }  return @queries;}## Do any conversions to the ANSI SQL query so that the database can handle it#sub query {  my($self,$sql) = @_;  return $sql;}sub drop_index{  my ($self,$table,$index) = @_;  return "DROP INDEX $table.$index";}## Abort if the server has crashed# return: 0 if ok#	  1 question should be retried#sub abort_if_fatal_error{  return 0;}sub small_rollback_segment{  return 0;}sub reconnect_on_errors{  return 0;}sub fix_for_insert{  my ($self,$cmd) = @_;  return $cmd;}##############################################################################	     Configuration for Sybase#############################################################################package db_sybase;sub new{  my ($type,$host,$database)= @_;  my $self= {};  my %limits;  bless $self;  $self->{'cmp_name'}		= "sybase";  $self->{'data_source'}	= "DBI:Sybase:database=$database";  if (defined($host) && $host ne "")  {    $self->{'data_source'}	.= ";hostname=$host";  }  $self->{'limits'}		= \%limits;  $self->{'blob'}		= "text";  $self->{'text'}		= "text";  $self->{'double_quotes'}	= 1; # Can handle:  'Walker''s'  $self->{'drop_attr'}		= "";  $self->{'transactions'}	= 1; # Transactions enabled  $self->{"vacuum"}		= 1;  $limits{'max_conditions'}	= 1030; # We get 'Query is too complex'  $limits{'max_columns'}	= 250;	# Max number of columns in table  $limits{'max_tables'}		= 65000;	# Should be big enough  $limits{'max_text_size'}	= 9830;  # Max size with default buffers.  $limits{'query_size'}		= 9830; # Max size with default buffers.  $limits{'max_index'}		= 64; # Max number of keys  $limits{'max_index_parts'}	= 15; # Max segments/key  $limits{'max_column_name'}	= 30; # max table and column name  $limits{'join_optimizer'}	= 1; # Can optimize FROM tables  $limits{'load_data_infile'}	= 0; # Has load data infile  $limits{'lock_tables'}	= 0; # Has lock tables  $limits{'functions'}		= 1; # Has simple functions (+/-)  $limits{'group_functions'}	= 1; # Have group functions  $limits{'group_func_sql_min_str'}	= 1; # Can execute MIN() and MAX() on strings  $limits{'group_distinct_functions'}= 1; # Have count(distinct)  $limits{'select_without_from'}= 1; # Can do 'select 1';  $limits{'multi_drop'}		= 1; # Drop table can take many tables  $limits{'subqueries'}		= 1; # Supports sub-queries.  $limits{'left_outer_join'}	= 1; # Supports left outer joins  $limits{'table_wildcard'}	= 1; # Has SELECT table_name.*  $limits{'having_with_alias'}  = 0; # Can use aliases in HAVING  $limits{'having_with_group'}	= 1; # Can't use group functions in HAVING  $limits{'like_with_column'}	= 1; # Can use column1 LIKE column2  $limits{'order_by_position'}  = 1; # Can use 'ORDER BY 1'  $limits{'group_by_position'}  = 0; # Can use 'GROUP BY 1'  $limits{'alter_table'}	= 1;  $limits{'alter_add_multi_col'}= 0;  $limits{'alter_table_dropcol'}= 0;  $limits{'group_func_extra_std'} = 0; # Have group function std().  $limits{'func_odbc_mod'}	= 0; # Have function mod.  $limits{'func_extra_%'}	= 1; # Has % as alias for mod()  $limits{'func_odbc_floor'}	= 1; # Has func_odbc_floor function  $limits{'func_extra_if'}	= 0; # Have function if.  $

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -