Feed on
Subscription

In realizing a watch, MySQL takes out random data

Be in before ? ? group in had discussed this issue, the grammar of relative interesting.mysql is really amused. The implementation that they think to use PHP so random, but take out many to seem to want to undertake above inquires twice. Translated manual, found below this statement, can finish the job.
? ?
? ? SELECT * FROM Table_name ORDER BY Rand() LIMIT 5;
? ?
? ? Rand is in manual so say:
? ? RAND()
? ? RAND(N)
? ? is returned in limits 0 be worth to the 1 random floating-point inside.If N of an integral parameter is appointed,It is used as a seed to be worth.
? ? Mysql%26gt;Select RAND();
? ? -%26gt;0.5925
? ? Mysql%26gt;Select RAND(20);
? ? -%26gt;0.1811
? ? Mysql%26gt;Select RAND(20);
? ? -%26gt;0.1811
? ? Mysql%26gt;Select RAND();
? ? -%26gt;0.2079
? ? Mysql%26gt;Select RAND();
? ? -%26gt;0.7888
? ?
? ? you cannot be worth use row with RAND() in clause of an ORDER BY,Because ORDER BY will repeat computation to be listed for many times.It is however in MySQL3.23,You can be done:SELECT * FROM Table_name ORDER BY RAND() ,This is to be helpful for getting one comes from SELECT * FROM Table1, the aggregate of Table2 WHERE A=b AND C%26lt;d ORDER BY RAND() LIMIT 1000 random sample.Notice a RAND() in clause of a WHERE will be in every time the reappraise when WHERE is carried out.
? ?
? ? but I tried, the watch of thousand 8 record, carry out need 0.08 Sec, . some slower
? ?
? ? consulted Google later, get following code
? ? SELECT *
? ? FROM Table_name AS R1 JOIN
? ? (SELECT ROUND(RAND() *
? ? (SELECT MAX(id)
? ? FROM Table_name)) AS Id)
? ? AS R2
? ? WHERE R1.id %26gt;= R2.id
? ? ORDER BY R1.id ASC
? ? LIMIT 5;
? ?
? ? carries out efficiency to need 0.02 Sec. Regrettablly is, have Mysql 4.1 only. * above just supports such child inquiry.

...

Series of database personnel at hand:Mysql field length

? ? lists the memory that the type needs to measure
? ?
Byte of ? ? TINYINT 1
? ?
? ? SMALLINT 2 byte
? ?
? ? MEDIUMINT 3 byte
? ?
? ? INT 4 byte
? ?
? ? INTEGER 4 byte
? ?
? ? BIGINT 8 byte
? ?
? ? FLOAT(X) 4 if X%26lt;= 24 or 8 if 25%26lt;= X%26lt;= 53
? ?
? ? FLOAT 4 byte
? ?
? ? DOUBLE 8 byte
? ?
? ? DOUBLE PRECISION 8 byte
? ?
? ? REAL 8 byte
? ?
? ? DECIMAL(M, d) M byte (D+2, if M%26lt;D)
? ?
? ? NUMERIC(M, d) M byte (D+2, if M%26lt;D)
? ?
? ? date and time kind
? ?
? ? lists the memory that the type needs to measure
? ?
? ? DATE 3 byte
? ?
? ? DATETIME 8 byte
? ?
? ? TIMESTAMP 4 byte
? ?
? ? TIME 3 byte
? ?
Byte of ? ? YEAR 1
? ?
? ? strings together a type
? ?
? ? lists the memory that the type needs to measure
? ?
Byte of ? ? CHAR(M) M,1 %26lt;= M %26lt;= 255
? ?
Byte of ? ? VARCHAR(M) L+1, in this L %26lt;= M and 1 %26lt;= M %26lt;= 255
? ?
? ? TINYBLOB, byte of TINYTEXT L+1, in this L%26lt;2 ^ 8
? ?
? ? BLOB, byte of TEXT L+2, in this L%26lt;2 ^ 16
? ?
? ? MEDIUMBLOB, byte of MEDIUMTEXT L+3, in this L%26lt;2 ^ 24
? ?
? ? LONGBLOB, byte of LONGTEXT L+4, in this L%26lt;2 ^ 32
? ?
? ? ENUM('value1' , 'value2' , . . . ) 1 or 2 byte, depend on the amount that enumerate is worth (maximum 65535)
? ?
? ? SET('value1' , 'value2' , . . . ) 1,2,3,4 or 8 byte, depend on the amount of gather member (most 64 members)

...

The Master/slave data synchronism of MYSQL is configured

The Master/slave data synchronism of ? ? MYSQL is configured
? ?
? ? my test environment. Basically data is instantaneous synchronism,The hope is helpful to everybody
? ?
? ? Redhat 9.0
? ? Mysql3.23.57
? ?
? ?Mysql data synchronism backs up
? ?
Server of ? ? A:192.168.1.2 advocate server Master
? ?
Server of ? ? B:Slave of 192.168.1.3 deputy server
? ?
Server of ? ? A is installed
? ?
P of - of U Root of - of ? ? #mysql
? ? Mysql%26gt;GRANT FILE ON * . * TO Backup@192.168.1.3 IDENTIFIED BY ' 1234 ' ;
? ? Mysql%26gt;\exit
? ?
It is Master opens password of Backup of date of a Zhang above ? ? 1234 give IP:192.168.1.3 have the limits of authority that archives handles
? ?
P Shutdown of - of U Root of - of ? ? Mysqladmin
? ?
? ? backs up Master place know exactly about sth occupies a library. . Use Tar statement normally.
? ?
Cvf /tmp/mysql.tar /var/lib/mysql of - of ? ? #tar
? ?
? ? notices: TAr when, mySQL is to should be below Stop circumstance
? ?
? ? is revised on A machine / Etc/my.cnf
? ?
? ? is in [parameter is joined inside Mysqld] section
? ?
? ? Log-bin
? ? Server-id=1
? ? Sql-bin-update-same
? ? Binlog-do-db=vbb
? ?
? ?Restart A server Mysql
? ?
? ? because have,join Log-bin parameter right now, because this begins to Index arose, be in / the transaction Log that there is database of.index record record below Var/lib/mysql catalog.
? ?
Server of ? ? B is installed
? ?
? ? set / Etc/my.cnf
? ?
? ? is in [Mysqld] section is joined
? ?
? ? Master-host=192.168.1.2
? ? Master-user=backup
? ? Master-password=1234
? ? Master-port=3306
? ? Server-id=2
? ? Master-connect-retry=60 is set beforehand try interval again 60 seconds
What ? ? Replicate-do-db=vbb tells Slave to do Vbb database only is newer
? ? Log-slave-updates
? ?
? ? goes to the Mysql.tar Copy on A on B
? ?
? ? passes B with Ftp / Tmp
? ?
? ? 9. Solution is compressed
? ? #cd /var/lib/
? ?
? ?The state checks
? ?
It is normal that ? ? 1.A follows B network and service below the circumstance, after carrying metabolic data by A, to B end scans data, whether does postmortem have undertake Replication? !
? ?
? ? 2. Imitate B is become machine, or it is B does not need to follow A to have link all the time certainly.
? ?
After ? ? will carry metabolic data by A, to the B end data that browse,B dot should change without data
? ?
? ? #tar Xvf /tmp/mysql-snapshot.tar
R Mysql:m of - of ? ? #chownYsql Mysql
? ?
? ? 1 restart the Mysql of B server
? ?
? ? is in at this moment / Var/lib/mysql catalog can appear Master.info, this record record the information of Master MySQL Server.
? ?
? ?The state checks
? ?
It is normal that ? ? 1.A follows B network and service below the circumstance, after carrying metabolic data by A, to B end scans data, whether does postmortem have undertake Replication? !
? ?
? ? 2. Imitate B is become machine, or it is B does not need to follow A to have link all the time certainly.
? ?
After ? ? will carry metabolic data by A, to the B end data that browse,B dot should change without data

...

SCO falls to compile the program that calls Mysql database with Gcc

? ? environment: SCO OpenServer 5.0.6, mysql 3.23.42, gcc 2.95.2
? ?
? ? remarks: GCc is compositive already the function that supports Mysql, can call a database directly in C source code, need not want to embed with ESQL/C in that way like Informix call.
? ?
File of ? ? 1.makefile
? ?
? ? CC=gcc
? ?
? ? LIB=-lcurses -lsocket -lmysqlclient -lm -lc -lnsl
? ?
? ? All:gSpser
? ?
? ? Gspser:gEt_data.o Getfileargv.o
? ?
? ? $(CC) -o Gj Get_data.o Getfileargv.o $(LIB)
? ?
? ? Get_data.o:gEt_data.c
? ?
? ? $(CC) -c Get_data.c
? ?
? ? Getfileargv.o:gEtfileargv.c
? ?
? ? $(CC) -c Getfileargv.c
? ?
? ? Clean:
? ?
? ? Rm -f *.o
? ?
File of ? ? 2.get_data.c
? ?
? ? #include %26lt;stdio.h%26gt;
? ?
? ? #include %26lt;/usr/local/mysql/include/mysql.h%26gt;
? ?
? ? #define DBCFG " . / Gsp.conf "
? ?
? ? Main()
? ?
? ? {
? ?
? ? Char Dbhost[32] , dbuser[16] , dbpasswd[16] , db[16];
? ?
? ? Char Query[256];
? ?
? ? Int Count;
? ?
? ? MYSQL * Mysql; /* expresses connective of pair of a database sentence handle */
? ?
? ? MYSQL_RES *mysql_res; /* represents the result */ that returns an inquiry of travel
? ?
*/ of array of string of ? ? MYSQL_ROW Mysql_row; /*
? ?
? ? My_ulonglong Rows;
? ?
? ? / * this type is used at travel number and Mysql_affected_rows() , Mysql_num_rows() and Mysql_insert_id()
? ?
? ? */
? ?
? ? Getfileargv(DBCFG, "DBHOST" , dbhost); /* is read from inside the file take Gsp.conf*/
? ?
? ? Getfileargv(DBCFG, "DBUSER" , dbuser);
? ?
? ? Getfileargv(DBCFG, "DBPASSWD" , dbpasswd);
? ?
? ? Getfileargv(DBCFG, "DATABASE" , db);
? ?
? ? If(! (Mysql=mysql_init(NULL))) /* is obtained or initialization */ of structure of a MYSQL
? ?
? ? {
? ?
? ? Rintf("mysql_init fails! ") ;
? ?
? ? Mysql_close(mysql);
? ?
? ? Exit(0);
? ?
? ? }
? ?
? ? If(! Mysql_real_connect(mysql, dbhost, dbuser, dbpasswd, db, 0, NULL, 0) )
? ?
? ? {/* joins server */ of a MySQL
? ?
? ? Rintf(" joins the server fails, contact systematic administrator please! ") ;
? ?
? ? Mysql_close(mysql);
? ?
? ? Exit(0);
? ?
? ? }
? ?
? ? Trcpy(query, "Select * From Zuh Where Jgm=\"11110501\" Order By Zuh");
? ?
? ? If(mysql_query(mysql, query)) /* carries out the SQL that appoints the string that is an empty ending to inquire */
? ?
? ? {
? ?
? ? Rintf("mysql_query makes mistake! ") ;
? ?
? ? Mysql_close(mysql);
? ?
? ? Exit(0);
? ?
? ? }
? ?
? ? Mysql_res=mysql_store_result(mysql); /* retrieves a whole result rally to give a client */
? ?
? ? Rows=mysql_num_rows(mysql_res); /* returns the quantitative */ of the row with heavy gather of a result
? ?
? ? If(rows==Code of 0) /* this government is nonexistent return */
? ?
? ? {
? ?
Return of value of ? ? Rintf(" is empty ");
? ?
? ? Mysql_free_result(mysql_res); /* releases the memory */ that gather of a result uses
? ?
? ? Mysql_close(mysql); /* shuts */ of join of a server
? ?
? ? Exit(0);
? ?
? ? }
? ?
? ? For(count=0; Count%26lt;rows; Count++ )
? ?
? ? {
? ?
? ? Mysql_row=mysql_fetch_row(mysql_res); /* acquires next group from inside assembling as a result */
? ?
Name of company of ? ? Rintf(" : %S " , mysql_row[0]);
? ?
Number of set of ? ? Rintf(" : %S " , mysql_row[1]);
? ?
Name of team of ? ? Rintf(" : %S\n" , mysql_row[2]);
? ?
? ? }
? ?
? ? Mysql_free_result(mysql_res);
? ?
? ? Mysql_close(mysql);
? ?
? ? }
? ?
File of ? ? 3.getfileargv.c
? ?
? ? #include %26lt;stdio.h%26gt;
? ?
? ? Int Getfileargv(const Char * Filename, const Char * Argvname, char * Retbuf)
? ?
? ? {
? ?
? ? FILE *fp;
? ?
? ? Char Line[128];
? ?
? ? Char Tempbuf[40];
? ?
? ? Trncpy(tempbuf, argvname, 30);
? ?
? ? Tempbuf[39]=0;
? ?
? ? If ((fp=fopen(filename, "R") )==NULL)
? ?
? ? Return -1;
? ?
? ? Trcat(tempbuf, "=");
? ?
? ? While(fgets(line, 120, fp) )
? ?
? ? {
? ?
? ? If(line[0]=='#' )
? ?
? ? Continue;
? ?
? ? If (! Strncmp(line, tempbuf, strlen(tempbuf)) )
? ?
? ? {
? ?
? ? Fclose(fp);
? ?
? ? Line[strlen(line)-1]=0;
? ?
? ? Trcpy(line, (Char *)(strchr(line, '=')+1));
? ?
? ? Trcpy(retbuf, line);
? ?
? ? Return 0;
? ?
? ? }
? ?
? ? }
? ?
? ? Fclose(fp);
? ?
? ? Return -2;
? ?
? ? }

...

MySQL is teeming plan of double machine imitate

? ? hardware is configured
? ?
Environment of the smallest group needs ? ? common PC Server * 2 (4 servers)
? ?
Environment of ? ? imitate
? ?
) of version of above of ? ? Red Hat Linux9 For X86 (or Red Hat AS 2, glibc-2.2, static, gcc
? ?
4.1.12 Binares of version of ? ? MySQL
? ?
Version of ? ? Mysql-max Binary supports Linux, Max Os X and Solaris only at present
? ?
This ? ? plan is not involved compile installation from source code
? ?
Utility of address of IP of ? ? lead plane
? ?
? ? Ndb1_mgmd_sqld 1192.168.1.100 Ndb Node1+mgmd Node1+sqld Node1
? ? Ndb2_sqld2 192.168.1.200 Ndb Node2+sqld Node2
? ?
? ? Mgmd:mAnagement Server
? ? Sqld:mYsql Server
? ? Ndb:sToraged Node (share-nothing, base In Memory)
? ?
? ? is installed
? ?
? ? arrives from Http://dev.mysql.com/downloads/mysql/4.1.html download Mysql-max-4.1.12-pc-linux-gnu-i686.tar.gz / Var/tmp
? ? Storage And SQL Node Installation
? ?
? ? carries out following processes on two lead plane
? ?
? ? Shell%26gt;groupadd Mysql
? ? Shell%26gt;useradd -g Mysql Mysql
? ? Shell%26gt;tar Zxfv Mysql-max-4.1.12-pc-linux-gnu-i686.tar.gz
? ? Shell%26gt;cp -vr Mysql-max-4.1.12-pc-linux-gnu-i686 /usr/local/mysql-max-4.1.12-pc-linux-gnu-i686
? ? Shell%26gt;cd /usr/local
? ? Shell%26gt;ln -s Mysql-max-4.1.12-pc-linux-gnu-i686 Mysql
User=mysql of - of ? ? Shell%26gt;cd Mysql;scripts/mysql_install_db
? ? Shell%26gt;chown -R Root. ;chown -R Mysql Data;chgrp -R Mysql.
? ? Shell%26gt;cp Support-files/mysql.server /etc/rc.d/init.d/
? ? Shell%26gt;chmod +x /etc/rc.d/init.d/mysql.server
? ? Shell%26gt;chkconfig- - Add Mysql.server
Level 3 Mysql.server Off of - of ? ? Shell%26gt;chkconfig
? ? Management Node Installation
? ?
? ? carries out following processes on lead plane Ndb1_mgmd_sqld1
? ?
? ? Shell%26gt;cd /var/tmp
? ? Shell%26gt;tar -zxvf Mysql-max-4.1.12a-pc-linux-gnu-i686.tar.gz /usr/local/bin '*/bin/ndb_mgm*'
? ? Configuration
? ? Configuring The Storage And SQL Nodes
? ?
? ? carries out following processes on two lead plane:
? ?
? ? Shell%26gt;vi /etc/my.cnf
? ? [# Options For Mysqld Process of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of MYSQLD] ? ? :
# Run NDB Engine of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? ? Ndbcluster
# Location Of MGM Node of ? of ? ? Ndb-connectstring=192.168.1.100
? ?
? ? [# Options For Ndbd Process of ? of ? of ? of ? of ? of ? of MYSQL_CLUSTER] ? ? :
# Location Of MGM Node of ? of ? ? Ndb-connectstring=192.168.1.100
? ?
? ? Configuring The Management Node
? ?
? ? carries out following processes on lead plane Ndb1_mgmd_sqld1
? ?
? ? Shell%26gt;mkdir /var/lib/mysql-cluster
? ? Shell%26gt;cd /var/lib/mysql-cluster
? ? Shell%26gt;vi Config.ini
? ? [# Options Affecting Ndbd Processes On All Data Nodes of ? of NDBD DEFAULT] ? :
# Number Of Replicas of ? of ? of ? ? NoOfReplicas=2
# How Much Memory To Allocate For Data Storage of ? of ? of ? ? DataMemory=80M
# How Much Memory To Allocate For Index Storage of ? of ? ? IndexMemory=52M
? ? # For DataMemory And IndexMemory, we Have Used The
? ? # Default Values. Since The "world" Database Takes Up
? ? # Only About 500KB, this Should Be More Than Enough For
? ? # This Example Cluster Setup.
? ? [TCP DEFAULT]
? ?
? ? [# Management Process Options of ? of ? of ? of ? of ? of NDB_MGMD] ? ? :
? ? Hostname=192.168.1.100 # Hostname Or IP Address Of MGM Node
# Directory For MGM Node Logfiles of ? of ? ? Datadir=/var/lib/mysql-cluster
? ?
? ? [# Options For Data Node "A" of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of NDBD] ? ? :
? ? # (one [NDBD] Section Per Data Node)
# Hostname Or IP Address of ? of ? of ? of ? of ? of ? ? HostName=192.168.1.100
# Directory For This Data Node's Datafiles of ? of ? ? DataDir=/usr/local/mysql/data
? ?
? ? [# Options For Data Node "B" of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of NDBD] ? ? :
# Hostname Or IP Address of ? of ? of ? of ? of ? of ? ? Hostname=192.168.1.200
# Directory For This Data Node's Datafiles of ? of ? ? Datadir=/usr/local/mysql/data
? ?
? ? [# SQL Node Options of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of MYSQLD] ? ? :
# Hostname Or IP Address of ? of ? of ? of ? of ? ? Hostname=192.168.1.100
? ? # Directory For SQL Node's Datafiles
? ? # (additional Mysqld Connections Can Be
? ? # Specified For This Node For Various
? ? # Purposes Such As Running Ndb_restore)
? ?
? ? [MYSQLD] # SQL Node Options:
# Hostname Or IP Address of ? of ? of ? of ? of ? ? Hostname=192.168.1.200
? ? # Directory For SQL Node's Datafiles
? ? # (additional Mysqld Connections Can Be
? ? # Specified For This Node For Various
? ? # Purposes Such As Running Ndb_restore)
? ?
? ? first time is started
? ?
? ? carries out following processes on lead plane Ndb1_mgmd_sqld1
? ?
? ? Shell%26gt;Ndb_mgmd -f /var/lib/mysql-cluster/config.ini
? ?
? ? carries out following processes on two lead plane
? ?
Initial (note:- of - of ? ? Shell%26gt;ndbd- Initial option can be used when be started for the first time only)
? ? Shell%26gt;/etc/init.d/mysql.server Start
? ?
? ? checks
? ?
? ? carries out following processes on lead plane Ndb1_mgmd_sqld1
? ? Shell%26gt;Ndb_mgm
? ?- - NDB Cluster- - Management Client- -
? ? Ndb_mgm%26gt;Show
? ? Connected To Management Server At: Localhost:1186
? ? Cluster Configuration
? ?---------------------
? ? [Ndbd(NDB)] ? ? 2 Node(s)
? of @192.168.0.100 of ? of ? of ? ? Id=2 (Version: 4.1.12, nodegroup: 0, master)
? of @192.168.0.200 of ? of ? of ? ? Id=3 (Version: 4.1.12, nodegroup: 0)
? ?
? ? [Ndb_mgmd(MGM)] 1 Node(s)
? of @192.168.0.100 of ? of ? of ? ? Id=1 (Version: 4.1.12)
? ?
? ? [Mysqld(SQL)] ? 1 Node(s)
? of ? ? Id=4 (Version: 4.1.12)
? ?
Information of ? ? occurrence as above states Mysql teeming installation is successful
? ?
Sampling test of ? ? data
? ?
? ? carries out following processes on lead plane Ndb1_mgmd_sqld1
? ?
? ? Shell%26gt;/usr/local/mysql/bin/mysql -u Root Test
? ? MySQL%26gt;DROP TABLE IF EXISTS City;
? ? CREATE TABLE City (
? ? ID Int(11) NOT NULL Auto_increment,
? ? Name Char(35) NOT NULL Default '' ,
? ? CountryCode Char(3) NOT NULL Default '' ,
? ? District Char(20) NOT NULL Default '' ,
? ? Population Int(11) NOT NULL Default '0' ,
? of ? ? PRIMARY KEY (ID)
? ? ) ENGINE=NDBCLUSTER;
? ?
? ? MySQL%26gt;INSERT INTO City VALUES (1, 'Kabul' , 'AFG' , 'Kabol' , 1780000);
? ? INSERT INTO City VALUES (2, 'Qandahar' , 'AFG' , 'Qandahar' , 237500);
? ? INSERT INTO City VALUES (3, 'Herat' , 'AFG' , 'Herat' , 186800);
? ?
? ? carries out following processes on lead plane Ndb2_sqld2
? ?
? ? Shell%26gt;/usr/local/mysql/bin/mysql -u Root Mysql
? ? MySQSL%26gt;select * From City;
? ?
If ? ? is successful indication data information,State group is started already successfully
? ?
? ? Safe Shutdown And Restart
? ?
? ? carries out following processes on lead plane Ndb1_mgmd_sqld1
? ?
? ? Shell%26gt;ndb_mgm -e Shutdown (shut group server,Storage Node also is met be shut automatically)
? ?
? ? carries out following processes on two lead plane
? ?
? ? Shell%26gt;/etc/init.d/mysql.server Stop
? ?
? ? starts group afresh (cannot make a mistake orderly)
? ?
? ? carries out following processes on lead plane Ndb1_mgmd_sqld1
? ?
? ? Shell%26gt;Ndb_mgmd -f /var/lib/mysql-cluster/config.ini
? ?
? ? carries out following processes on two lead plane
? ?
? ? Shell%26gt;/usr/local/mysql/bin/ndbd
? ?
Sqld process is started after ? ? starts Ndbd process
? ?
? ? Shell%26gt;/etc/init.d/mysql.server Start
? ?
? ? is added:
? ?
Departmental cent explains in ? ? Config.ini
? ?
? ? [COMPUTER] : Define teeming lead plane.
? ?
? ? [NDBD] : Define teeming data node.
? ?
? ? [MYSQLD] : Define Sql Server node.
? ?
? ? [MGM | NDB_MGMD] : Defines The Management Server Node In The Cluster.
? ? [TCP] : Defines TCP/IP Connections Between Nodes In The Cluster, with TCP/IP Being The Default Connection Protocol.
? ? [SHM] : Defines Shared-memory Connections Between Nodes. Before MySQL 4.1.9,This function must be used- - With-ndb-shm Option is compiled go in, begin from MySQL 4.1.9-max version, it Is Enabled By Default

...

Release MySQL group to install script automatically 1

? ? 1. Script Install.sh is built below catalog of MySQL source code,In adding the code below to this script:
? ?
? ? # ! / Bin/bash
? ? #####################################################
? ? ## Title: ## of ? of ? of MySQL 4.1 Cluster Installation Script
? ? ## Version: ## of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of 1 ? ?
? ? ## Date: ## of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of 2004-11-11 ? ?
? ? ## Author: ## of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of Yipsilon ? ?
? ? ## Email: ## of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of Yipsilon@163.com ? ?
? ? ## License: ## of ? of ? of ? of ? of ? of General Public License (GPL)
? ? ## Copyright(c) 2004, yipsilon All Rights Reserved ##
? ? #####################################################
## of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ChangeLog of ? of ? of ? of ? of ? of ? of ? of ? of ? ? ##
? ? #####################################################
## of ? of ? of ? of ? of ? of ? of ? of ? of ? of Installation Guide of ? of ? of ? of ? of ? of ? of ? ? ##
? of ? ? ## 1. Copy The Script File Into Mysql Source Path ##
? of ? ? ## 2. ## of ? of ? of ? of Change Script File's Permission To 755
? of ? ? ## 3. Execute It And Wait For. . . ## of ? of ? of ? of ? of ? of ? of ? ? ?
? ? #####################################################
? ? ############################################
? ? ######### MySQL Server Config ##############
? ? ############################################
? ? #Determine To Install MySQL Server
? ? #"0" Means Do Not Install Server Programs
? ? INST_SERVER=1
? ? #MySQL Installation Path
? ? INST_PATH="/usr/local/mysql "
? ? #Define The Ports Of MySQL Installation, intput Strings Of PORT With Whitespace Separated.
? ? #e.g. "3306 3307" Means Install Two MySQL Servers:
The First Server Will Be Installed To $INST_PATH/1 And Listen 3306 Port of ? of ? of ? ? # .
The Second Server Will Be Installed To $INST_PATH/2 And Listen 3307 Port of ? of ? of ? ? # .
? ? of ? ? # . . . . . .
? ? INST_PORTS="3306 "
? ? #The Management Server Information
? ? MGM_HOST="192.168.1.253 "
? ? MGM_PORT="2200 "
? ? ###########################################
? ? ######### MySQL Cluster Config ############
? ? ###########################################
? ? #Determine To Install Cluster
? ? #"0" Means Do Not Install Cluster Programs
? ? INST_CLUSTER=1
? ? #Define COMPUTERs In Config.ini, intput Strings Of HostName With Whitespace Separated.
? ? #The Id Attribute Is Auto Increment And Start With 1.
? ? #e.g. "192.168.1.253 192.168.252" Will Generate The Following Code
? of ? ? # [COMPUTER]
Id=1 of ? of ? of ? ? #
HostName=192.168.1.253 of ? of ? of ? ? #
? of ? ? # [COMPUTER]
Id=2 of ? of ? of ? ? #
HostName=192.168.1.252 of ? of ? of ? ? #
? ? COMPUTERS="192.168.1.253 192.168.1.252 "
? ? #Define MGMs In Config.ini, intput Strings Of HostName With Whitespace Separated.
? ? #e.g. "192.168.1.253 192.168.252" Will Generate The Following Code
? of ? ? # [MGM]
HostName=192.168.1.253 of ? of ? of ? ? #
? of ? ? # [MGM]
HostName=192.168.1.252 of ? of ? of ? ? #
? ? MGMS="192.168.1.253 "
? ? #Define DBs In Config.ini, intput Ids Of ExecuteOnComputer With Whitespace Separated.
? ? #e.g. "1 2" Will Generate The Following Code
? of ? ? # [DB]
ExecuteOnComputer=1 of ? of ? of ? ? #
? of ? ? # [DB]
ExecuteOnComputer=2 of ? of ? of ? ? #
? ? DBS="1 "
? ? #Define APIs In Config.ini, intput Ids Of ExecuteOnComputer With Whitespace Separated.
? ? #e.g. "1 0 1 2" Will Generate The Following Code
? of ? ? # [API]
ExecuteOnComputer=1 of ? of ? of ? ? #
? of ? ? # [API]
? of ? ? # [API]
ExecuteOnComputer=1 of ? of ? of ? ? #
? of ? ? # [API]
ExecuteOnComputer=2 of ? of ? of ? ? #
? ? APIS="1 0 2 2 "
? ? ######################################################################
? ? ########## Starting To Install Programs, do Not Modify Them! #########
? ? ######################################################################
? ? Echo "Starting To Install Programs "%26gt;Install.log
? ? #Find Installation Path
? ? If [$# -gt 0]
? ? Then
? ? INST_PATH="$1 "
? ? Else
? ? INST_PATH="/usr/local/mysql "
? ? Fi
? ? If [0 -lt $INST_SERVER]
? ? Then
? ? Echo "Now, installing The MySQL Servers. . . ..
? ?
? ? #Loop To Install Mysql Servers
? ? INSTALLED_SERVER_COUNT=1
? ? For PORT In $INST_PORTS
? ? Do
? ? #Define The Current Mysql Server Installation Path
? ? MYSL_PATH=$INST_PATH/$INSTALLED_SERVER_COUNT
? ?
? ? #Configure Mysql Server
? ? Echo "Exec. / Configure- - Prefix=$MYSL_PATH- - With-pthread- - With-unix-socket-path=$MYSL_PATH/var/mysql.sock- - With-mysqld-user=root- - With-tcp-port=$PORT- - With-charset=gbk- - With-ndbcluster%26quot; %26gt;%26gt;Install.log
? ? . / Configure- - Prefix=$MYSL_PATH- - With-pthread- - With-unix-socket-path=$MYSL_PATH/var/mysql.sock- - With-mysqld-user=root- - With-tcp-port=$PORT- - With-charset=gbk- - With-ndbcluster
? ?
? ? #Make Mysql Server
? ? Echo %26quot;Exec Make %26amp;%26amp;Make Install%26quot; %26gt;%26gt;Install.log
? ? Make %26amp;%26amp;Make Install
? ?
? ? #Create Var Directory For Mysql Data
? ? Mkdir -p $MYSL_PATH/var
? ?
? ? #Create My.cnf
? ? Echo %26quot;Create $MYSL_PATH/var/my.cnf%26quot; %26gt;%26gt;Install.log
? ? Echo "[client] "%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;port=$PORT%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;socket=$MYSL_PATH/var/mysql.sock%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;[mysqld]%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;ndbcluster%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo "ndb_connectstring=host=$MGM_HOST:$MGM_PORT%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;user=root%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;port=$PORT%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;basedir=$MYSL_PATH/%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;datadir=$MYSL_PATH/var/%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;socket=$MYSL_PATH/var/mysql.sock%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;default-character-set=gbk%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;default-storage-engine=INNODB%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;max_connections=500%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;query_cache_size=33M%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;table_cache=1520%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;tmp_table_size=16M%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;thread_cache=38%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;#MyISAM Specific Options%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;#skip-myisam%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;#INNODB Specific Options%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;#skip-innodb%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Chmod 755 $MYSL_PATH/var/my.cnf
? ?
? ? #Install Mysql Database
? ? Echo %26quot;Exec $MYSL_PATH/bin/mysql_install_db%26quot; %26gt;%26gt;Install.log
? ? $MYSL_PATH/bin/mysql_install_db
? ?
? ? #Create Mysql Control Script
? ? If [-e $MYSL_PATH/share/mysql/mysql.server]
? ? Then
? ?
? ? #Use Default Mysql Control Script
? ?
? ? #Create Mysql Server Start Script
? ? Echo %26quot;Create $MYSL_PATH/start%26quot; %26gt;%26gt;Install.log
? ? Echo "$MYSL_PATH/share/mysql/mysql.server Start "%26gt;$MYSL_PATH/start
? ? Echo %26quot;Chmod 755 $MYSL_PATH/start%26quot; %26gt;%26gt;Install.log
? ? Chmod 755 $MYSL_PATH/start
? ?
? ? #Create Mysql Server Stop Script
? ? Echo %26quot;Create $MYSL_PATH/stop%26quot; %26gt;%26gt;Install.log
? ? Echo "$MYSL_PATH/share/mysql/mysql.server Stop "%26gt;$MYSL_PATH/stop
? ? Echo %26quot;Chmod 755 $MYSL_PATH/stop%26quot; %26gt;%26gt;Install.log
? ? Chmod 755 $MYSL_PATH/stop
? ?
? ? #Create Mysql Server Restart Script
? ? Echo %26quot;Create $MYSL_PATH/restart%26quot; %26gt;%26gt;Install.log
? ? Echo "$MYSL_PATH/share/mysql/mysql.server Restart "%26gt;$MYSL_PATH/restart
? ? Echo %26quot;Chmod 755 $MYSL_PATH/restart%26quot; %26gt;%26gt;Install.log
? ? Chmod 755 $MYSL_PATH/restart
? ? Else
? ?
? ? #Use Custom Mysql Control Script
? ?
? ? #Create Mysql Server Start Script
? ? Echo %26quot;Create $MYSL_PATH/start%26quot; %26gt;%26gt;Install.log
? ? Echo %26quot;$MYSL_PATH/libexec/mysqld %26amp; %26quot;%26gt;$MYSL_PATH/start
? ? Echo %26quot;Chmod 755 $MYSL_PATH/start%26quot; %26gt;%26gt;Install.log
? ? Chmod 755 $MYSL_PATH/start
? ?
? ? #Create Mysql Server Stop Script
? ? Echo %26quot;Create $MYSL_PATH/stop%26quot; %26gt;%26gt;Install.log
? ? Echo "$MYSL_PATH/bin/mysqladmi

...

Of MYSQL study data make mistake code list

? ? 1005:Found watch failure
? ?
? ? 1006:Found database failure
? ?
? ? 1007:The database already existed,Found database failure
? ?
? ? 1008:The database is nonexistent,Cutout fails except the database
? ?
? ? 1009:Cannot delete database file to bring about cutout to fail except the database
? ?
? ? 1010:Cannot delete data catalog to bring about cutout to fail except the database
? ?
? ? 1011:Cutout fails except database file
? ?
? ? 1012:Cannot read the record in taking a system to express
? ?
? ? 1020:The record already was revised by other user
? ?
? ? 1021:The space is not worth hard disk the rest,Increase hard disk to be able to use a space please
? ?
? ? 1022:Key word repeats,Change record failure
? ?
? ? 1023:The mistake happens when shutting
? ?
? ? 1024:Read file mistake
? ?
? ? 1025:The mistake happens when changing a name
? ?
? ? 1026:Write file mistake
? ?
? ? 1032:The record is nonexistent
? ?
? ? 1036:Data table is read-only,Cannot undertake modification to it
? ?
? ? 1037:Systematic memory is insufficient,Restart please database or restart server
? ?
? ? 1038:At the memory inadequacy of sort with,Increase sort buffer please
? ?
? ? 1040:The biggest join that already arrived at a database is counted,Increase a database to be able to use join number please
? ?
? ? 1041:Systematic memory is insufficient
? ?
? ? 1042:Invalid leader name
? ?
? ? 1043:Invalid join
? ?
? ? 1044:Current user did not visit the attributive of the database
? ?
? ? 1045:Cannot join database,User name or password are wrong
? ?
? ? 1048:The field cannot is empty
? ?
? ? 1049:The database is nonexistent
? ?
? ? 1050:Data table already existed
? ?
? ? 1051:Data table is nonexistent
? ?
? ? 1054:The field is nonexistent
? ?
? ? 1065:Invalid SQL statement,SQL statement is empty
? ?
? ? 1081:Cannot establish Socket link
? ?
? ? 1114:Data list is full already,Cannot hold any records
? ?
? ? 1116:The data table that open is too much
? ?
? ? 1129:The database appears unusual,Restart please database
? ?
? ? 1130:Join database fails,Without the attributive of join database
? ?
? ? 1133:Database user is nonexistent
? ?
? ? 1141:Current user has no right to visit a database
? ?
? ? 1142:Current user has no right to visit data table
? ?
? ? 1143:Current user has no right to visit data to express medium field
? ?
? ? 1146:Data table is nonexistent
? ?
? ? 1147:Did not define the visit limits of authority that the user expresses to data
? ?
? ? 1149:SQL statement solecism
? ?
? ? 1158:Network mistake,Occurrence misread by accident,Inspect network join condition please
? ?
? ? 1159:Network mistake,Read overtime,Inspect network join condition please
? ?
? ? 1160:Network mistake,Occurrence clerical error by accident,Inspect network join condition please
? ?
? ? 1161:Network mistake,Write overtime,Inspect network join condition please
? ?
? ? 1062:Field value repeats,Put in storage fails
? ?
? ? 1169:Field value repeats,Newer record fails
? ?
? ? 1177:Open data to express failure
? ?
? ? 1180:Refer clerical failure
? ?
? ? 1181:Time roll clerical failure
? ?
? ? 1203:The biggest join that the link that current user and database establish already arrived at a database is counted,Increase practicable database to join is counted or restart please database
? ?
? ? 1205:Add lock overtime
? ?
? ? 1211:Current user did not establish the limits of authority of the user
? ?
? ? 1216:External key tie examines failure,Newer child souvenir records failure
? ?
? ? 1217:External key tie examines failure,Delete or revise advocate souvenir records failure
? ?
? ? 1226:The resource that the resource that current user uses already allowed more than,Restart please database or restart server
? ?
? ? 1227:Attributive is insufficient,You have no right to undertake this is operated
? ?
? ? 1235:MySQL version is too low,Do not have this function

...

The extraction of all sorts of fields of the MySQL in the database is worth limits

? ? TINYINT
? ?
? ? - 128 - 127
? ?
? ? TINYINT UNSIGNED
? ?
? ? 0 - 255
? ?
? ? SMALLINT
? ?
? ? - 32768 - 32767
? ?
? ? SMALLINT UNSIGNED
? ?
? ? 0 - 65535
? ?
? ? MEDIUMINT
? ?
? ? - 8388608 - 8388607
? ?
? ? MEDIUMINT UNSIGNED
? ?
? ? 0 - 16777215
? ?
? ? INT or INTEGER
? ?
? ? - 2147483648 - 2147483647
? ?
? ? INT UNSIGNED or INTEGER UNSIGNED
? ?
? ? 0 - 4294967295
? ?
? ? BIGINT
? ?
? ? - 9223372036854775808 - 9223372036854775807
? ?
? ? BIGINT UNSIGNED
? ?
? ? 0 - 18446744073709551615
? ?
? ? FLOAT
? ?
? ? - 3.402823466E+38 - -1.175494351E-38
? ?
? ? 0
? ?
? ? 1.175494351E-38 - 3.402823466E+38
? ?
? ? DOUBLE or DOUBLE PRECISION or REAL
? ?
? ? - 1.7976931348623157E+308 - -2.2250738585072014E-308
? ?
? ? 0
? ?
? ? 2.2250738585072014E-308 - 1.7976931348623157E+308
? ?
? ? DECIMAL[(M, [D])] or NUMERIC(M, d)
? ?
? ? by the length of M(whole number, include decimally, the digit of decimally left, the digit of decimally right, but do not include negative sign) the digit with D(decimally right) will decide, m default is 10, d default is 0
? ?
? ? DATE
? ?
? ? 1000-01-01 - 9999-12-31
? ?
? ? DATETIME
? ?
? ? 1000-01-01 00:00:00 - 9999-12-31 23:59:59
? ?
? ? TIMESTAMP
? ?
? ? 1970-01-01 00:00:00 - 2037 year one of these day (specific it is I also do not know where day, ah)
? ?
? ? TIME
? ?
? ? - 838:59:59' To 838:59:59
? ?
? ? YEAR[(2 | 4) ]
? ?
? ? default is 4 formats, 4 formats take value scope to be 1901 - 2155, 0000, 2 formats take value scope to be 70-69(1970-2069)
? ?
? ? CHAR(M) [BINARY] or NCHAR(M) [BINARY]
? ?
The limits of ? ? M is 1 - 255, if do not have BINARY, do not distribute big small letter, NCHAR expresses to use default character set. In the database with blank space complemental, but last when be taken blank space will be automatic take out.
? ?
? ? [NATIONAL] VARCHAR(M) [BINARY]
? ?
The limits of ? ? M is 1 - 255. Last in the database blank space will be automatic take out.
? ?
? ? TINYBLOB or TINYTEXT
? ?
? ? 255(2^8-1) character
? ?
? ? BLOB or TEXT
? ?
? ? 65535(2^16-1) character
? ?
? ? MEDIUMBLOB or MEDIUMTEXT
? ?
? ? 16777215 (2^24-1) character
? ?
? ? LONGBLOB or LONGTEXT
? ?
? ? 4294967295 (2^32-1) character
? ?
? ? ENUM('value1' , 'value2' , . . . ..
? ?
? ? always can share 65535 different costs
? ?
? ? SET('value1' , 'value2' , . . . ..

...

MySQL:How to install a password for the user

? ? is become the first time when Mysql is installed on the machine, you are OK and faceless undertake visitting a database to perhaps enter a database with bringing the Root capacity of countersign. Additional if you are an administrator, you have a few users even build reach accredit, this involves the issue that sets a password again. We discuss how to install a password below:
? ?
? ? above all the countersign memory that we should know Mysql database is medium must be added with Password() function close it. Because be in User watch,store in order to add close form countersign, is not to serve as simple text. If you were not added close, carry out the following statement in the database directly:
? ?
? ? Use Mysql
? ?
? ? Insert Into User (host, user, password) Values('%' , 'user_name' , 'your Password');
? ?
? ? Flush Privileges;
? ?
? ? believes the result won't make you satisfactory. Because the server is relative,be to increase close cost, so server join fails certainly. What the specification needs here is Flush Privileges; table of accredit of new to load reached since this command. You also can fall to use Mysqladmin -u Root Reload directly in Shell or Mysqladmin -u Root Flush-privileges will realize burden accredit watch.
? ?
? ? falls in Mysql environment, you can use the following statement to undertake installing a password:
? ?
? ? 1.insert Into User(host, user, password) Values('%' , 'user_name' , password("your Password");
? ?
? ? 2.set Password For User_name = Password("your Password" )
? ?
Two kinds of methods must undertake ? ? above burden accredit watch.
? ?
? ? 3. The password is installed directly when you also are founding an user of course, grant statement will add close countersign automatically for you.
? ?
? ? is like Grant All On * . * To User_name@% Identified By "your Password";
? ?
Additionally you also can be in ? ? the password is installed below Shell environment with Mysqladmin program
? ?
? ? is like Mysqladmin -u Root Password "your Password "

...

The MySQL UDF on Windows develops application

The BUG that ? ? ever thought the MySQL existence of Windows version cannot use UDF all referred a Bug to report.Discovering it seems that nevertheless is I made a mistake,The technical support staff of MySQL gave very perfect solve,Commensurate home is shared.Below is textual reply.
? ?
? ? user hello.Feel sorry,This is not a Bug.Below I am stickup the brief example that makes for a certain client before,Assume you had VC++ , the source is distributed,The MySQL server that and have moves normally.
? ?
? ? my general founds an UDF it a name:
? ?
? ? notices: ?oil up of bud of Sun of illicit of Lin of fawn on of live abroad of health neon of ? of ? of Ke of ? Yong shallow < not ? Xing sluggish returns ? DF.
? ?
? ? - open area of Mysqld.dsw work.
? ?
? ? - add new project to this work area
? ?
? ? - Project Name: Name of project of My_udf // : MY_udf
? ?
? ? - dynamic link library of choice Win32 Dynamic-Link Library // Win32
? ?
? ? - click OK
? ?
? ? - choose An Empty DLL Project // project of an empty DLL
? ?
? ? - click Finish
? ?
? ? - click OK
? ?
? ? - in adding new document My_udf.cpp to the project:
? ?
? ? #include
? ?
? ? #include
? ?
? ? #include
? ?
? ? Extern "C" {
? ?
? ? Char *my_name(UDF_INIT *initid, UDF_ARGS *args, char *is_null,
? ?
? ? Char *error);
? ?
? ? / / compatible C
? ?
? ? }
? ?
? ? Char *my_name(UDF_INIT *initid, UDF_ARGS *args, char *is_null,
? ?
? ? Char *error)
? ?
? ? {
? ?
? ? Char * Me = "my Name";
? ?
? ? Return Me;
? ?
? ? / / call this UDF to will return My Name
? ?
? ? }
? ?
? ? - will found a new document by Ctrl+N.
? ?
? ? - type of choice Text
? ?
? ? - File Name: Name of My_udf.def File:// file: MY_udf.def
? ?
? ? - compile a document according to the content of below.
? ?
? ? LIBRARY UDF_EXAMPLE
? ?
? ? DESCRIPTION 'Example Using UDF With VC++'
? ?
? ? VERSION 1.0
? ?
? ? EXPORTS
? ?
? ? My_name
? ?
? ? - right attack My_udf project and choose Settings
? ?
? ? - option of dot C/C++ gets stuck
? ?
? ? - choose General
? ?
? ? - add grand HAVE_DLOPE arrives pretreatment implement definition
? ?
? ? - choose Preprocessor
? ?
? ? - add head file way: Additional Include Directories
? ?
? ? for example: . . / Include
? ?
? ? - go compiling DLL by F7.
? ?
? ? - the list that duplicate My_udf.dll has defined to environmental variable Path
? ?
? ? for instance \winnt\system32.
? ?
? ? - open Mysql client end
? ?
? ? C:\Mysql-udf\bin%26gt;mysql -uroot -p
? ?
? ? Enter Password:
? ?
? ? Welcome To The MySQL Monitor. Commands End With; Or \g.
? ?
? ? Your MySQL Connection Id Is 2 To Server Version: 3.23.52-max-nt
? ?
? ? Type 'help;' Or '\h' For Help. Type '\c' To Clear The Buffer.
? ?
? ? Mysql%26gt;CREATE FUNCTION My_name RETURNS STRING SONAME "my_udf.dll";
? ?
? ? Query OK, 0 Rows Affected (0.08 Sec)
? ?
? ? Mysql%26gt;Select My_name();
? ?
? ? Mysql%26gt;Drop Function My_name;
? ?
? ? Query OK, 0 Rows Affected (0.00 Sec)
? ?
The letter in reply that MySQL technology personnel is under ? ? is textual:
? ?
? ? Sorry This Isn't A Bug.
? ?
? ? Below I Pasted A Sample I Did Sometime Ago For Another User:
? ?
? ? Ok. Assuming You Have VC++ And The Source Distribution And A Server
? ?
? ? Running,
? ?
? ? I Will Create A UDF That Returns A Name:
? ?
? ? Note: The Sample Is Ugly, but The Purpose Here Is To Show You How
? ?
? ? To Handle The UDF.
? ?
? ? - Open The Mysqld.dsw Workspace.
? ?
? ? - Add New Project To The Workspace
? ?
? ? - Project Name: My_udf
? ?
? ? - Select Win32 Dynamic-Link Library
? ?
? ? - Click OK
? ?
? ? - Select An Empty DLL Project
? ?
? ? - Click Finish
? ?
? ? - Click OK
? ?
? ? - Add A New File Called My_udf.cpp To The Project:
? ?
? ? #include
? ?
? ? #include
? ?
? ? #include
? ?
? ? Extern "C" {
? ?
? ? Char *my_name(UDF_INIT *initid, UDF_ARGS *args, char *is_null,
? ?
? ? Char *error);
? ?
? ? }
? ?
? ? Char *my_name(UDF_INIT *initid, UDF_ARGS *args, char *is_null,
? ?
? ? Char *error)
? ?
? ? {
? ?
? ? Char * Me = "my Name";
? ?
? ? Return Me;
? ?
? ? }
? ?
? ? - Type Ctrl+N For To Create A New File.
? ?
? ? - Select Text Type
? ?
? ? - File Name: My_udf.def
? ?
? ? - Edit The Above File With The Below Contents:
? ?
? ? LIBRARY UDF_EXAMPLE
? ?
? ? DESCRIPTION 'Example Using UDF With VC++'
? ?
? ? VERSION 1.0
? ?
? ? EXPORTS
? ?
? ? My_name
? ?
? ? - Right Click The My_udf Project And Select Settings
? ?
? ? - Click The C/C++ Tab
? ?
? ? - Select General In The Category Combo
? ?
? ? - Add The Macro HAVE_DLOPEN To The PreProcessor Definition
? ?
? ? - Select Preprocessor In The Category Combo
? ?
? ? - Add The Include Path To The Text Box: Additional Include Directories
? ?
? ? E.g: . . / Include
? ?
? ? - Press F7 For To Build The DLL.
? ?
? ? - Copy The My_udf.dll To The Environment Path Directory:
? ?
? ? \winnt\system32 For Example.
? ?
? ? - Start The Mysql Client And Issue:
? ?
? ? C:\Mysql-udf\bin%26gt;mysql -uroot -p
? ?
? ? Enter Password:
? ?
? ? Welcome To The MySQL Monitor. Commands End With; Or \g.
? ?
? ? Your MySQL Connection Id Is 2 To Server Version: 3.23.52-max-nt
? ?
? ? Type 'help;' Or '\h' For Help. Type '\c' To Clear The Buffer.
? ?
? ? Mysql%26gt;CREATE FUNCTION My_name RETURNS STRING SONAME "my_udf.dll";
? ?
? ? Query OK, 0 Rows Affected (0.08 Sec)
? ?
? ? Mysql%26gt;Select My_name();
? ?
? ? Mysql%26gt;Drop Function My_name;
? ?
? ? Query OK, 0 Rows Affected (0.00 Sec)

...
« 首页...« 7 8 9 10 11 12 13 14 15 16 17 18 19 20 »...尾页 »