package com.wxpn.tutorial.db;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.Statement;
import java.util.Date;
/**
* ÃèÊö: Êý¾Ý¿âÁ¬½Ó³ØÀà
*
*
* @version 1.0
*/
public class ConnectionPool implements Runnable {
private boolean _debug = false;
private Thread runner;
private Connection[] connPool;
private int[] connStatus; // (0) available; (1) locked by the client; (2)
// locked by the housekeeping thread
private long[] connLockTime;
private long[] connCreateTime;
private String[] connID;
private String dbdriver, dbserver, dbuser, dbpassword;
private int currConnections, connLast, minconns, maxconns, maxconnMSec;
// available: set to false on destroy, checked by getConnection()
private boolean available = true;
private SQLWarning c ......
package com.wxpn.tutorial.db;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.Statement;
import java.util.Date;
/**
* ÃèÊö: Êý¾Ý¿âÁ¬½Ó³ØÀà
*
*
* @version 1.0
*/
public class ConnectionPool implements Runnable {
private boolean _debug = false;
private Thread runner;
private Connection[] connPool;
private int[] connStatus; // (0) available; (1) locked by the client; (2)
// locked by the housekeeping thread
private long[] connLockTime;
private long[] connCreateTime;
private String[] connID;
private String dbdriver, dbserver, dbuser, dbpassword;
private int currConnections, connLast, minconns, maxconns, maxconnMSec;
// available: set to false on destroy, checked by getConnection()
private boolean available = true;
private SQLWarning c ......
ÍøÕ¾µÄÊý¾Ý¿âÊǵ÷ÓÃÔ¶³Ì·þÎñÆ÷ÉϵÄ,²»ÊDZ¾»úµÄ.ÍøÕ¾´ò¿ª±È½ÏÂý.ÔÚÍøÉÏËÑË÷ÁË·½·¨,Õâ¸ö·½·¨¿ÉÒÔ½â¾ö,µ«ÊÇÓÐÁíÍâµÄÎÊÌâ³öÏÖ:
-----------------------------------------------------------------------
ÔÚ¾ÖÓòÍøÄÚÁ¬½ÓÆäËû»úÆ÷µÄMYSQL,·¢ÏÖËÙ¶ÈÂýµÄºÜ,²»ÖªµÀʲôÔÒò,×ÜÓм¸ÃëµÄÑÓ³Ù.
ºóÀ´ÔÚÍøÉÏ·¢ÏÖ½â¾ö·½·¨,my.iniÀïÃæÌí¼Ó
[mysqld]
skip-name-resolve
skip-grant-tables
ÕâÑùËٶȾͿìÁË!
skip-name-resolve
Ñ¡Ïî¾ÍÄܽûÓÃDNS½âÎö£¬Á¬½ÓËٶȻá¿ìºÜ¶à¡£²»¹ý£¬ÕâÑùµÄ»°¾Í²»ÄÜÔÚMySQLµÄÊÚȨ±íÖÐʹÓÃÖ÷»úÃûÁ˶øÖ»ÄÜÓÃip¸ñʽ¡£
ÈôʹÓÖskip-grant-tablesϵͳ½«¶ÔÈκÎÓû§µÄ·ÃÎʲ»×öÈκηÃÎÊ¿ØÖÆ£¬µ«¿ÉÒÔÓà mysqladmin flush-privileges»òmysqladmin reloadÀ´¿ªÆô·ÃÎÊ¿ØÖÆ;ĬÈÏÇé¿öÊÇshow databasesÓï¾ä¶ÔËùÓÐÓû§¿ª·Å£¬
Èç¹ûmysql·þÎñÆ÷ûÓпªÔ¶³ÌÕÊ»§£¬¾ÍÔÚmy.iniÀïÃæ¼ÓÉÏskip-grant-tables
------------------------------------------------------------------
ÔÚMYSQLD¼ÓÈëÁËÄÇÁ½ÌõÃüÁîºó·¢ÏÖϵͳ½«¶ÔÈκÎÓû§µÄ·ÃÎʲ»×öÈκηÃÎÊ¿ØÖÆ.ÕâÑùÓе㲻°²È«,ÏëʹÓà mysqladmin flush-privileges»òmysqladmin reloadÀ´¿ªÆô·ÃÎÊ¿ØÖÆ,µ«ÊDz»ÖªµÀÕâ¸öÃüÁî¼ÓÔÚÄÄÀï.ͬ ......
MySQL·ÖÇø£¨Partition£©¹¦ÄÜÊÔÑé2008-07-06 20:02Ŀ¼
[¸ÅÊö]
[·ÖÇø±íºÍδ·ÖÇø±íÊÔÑé¹ý³Ì]
[·ÖÇøÃüÁîÏê½â]
[¸ÅÊö]
×Ô5.1¿ªÊ¼¶Ô·ÖÇø(Partition)ÓÐÖ§³Ö£¬6.0Ó¦±È½ÏÎȶ¨
= ˮƽ·ÖÇø£¨¸ù¾ÝÁÐÊôÐÔ°´Ðз֣©=
¾Ù¸ö¼òµ¥Àý×Ó£ºÒ»¸ö°üº¬Ê®Ä귢Ʊ¼Ç¼µÄ±í¿ÉÒÔ±»·ÖÇøΪʮ¸ö²»Í¬µÄ·ÖÇø£¬Ã¿¸ö·ÖÇø°üº¬µÄÊÇÆäÖÐÒ»ÄêµÄ¼Ç¼¡£
=== ˮƽ·ÖÇøµÄ¼¸ÖÖģʽ£º===
* Range£¨·¶Î§£© – ÕâÖÖģʽÔÊÐíDBA½«Êý¾Ý»®·Ö²»Í¬·¶Î§¡£ÀýÈçDBA¿ÉÒÔ½«Ò»¸ö±íͨ¹ýÄê·Ý»®·Ö³ÉÈý¸ö·ÖÇø£¬80Äê´ú£¨1980's£©µÄÊý¾Ý£¬90Äê´ú£¨1990's£©µÄÊý¾ÝÒÔ¼°ÈκÎÔÚ2000Ä꣨°üÀ¨2000Ä꣩ºóµÄÊý¾Ý¡£
* Hash£¨¹þÏ££© – ÕâÖÐģʽÔÊÐíDBAͨ¹ý¶Ô±íµÄÒ»¸ö»ò¶à¸öÁеÄHash Key½øÐмÆË㣬×îºóͨ¹ýÕâ¸öHashÂ벻ͬÊýÖµ¶ÔÓ¦µÄÊý¾ÝÇøÓò½øÐзÖÇø£¬¡£ÀýÈçDBA¿ÉÒÔ½¨Á¢Ò»¸ö¶Ô±íÖ÷¼ü½øÐзÖÇøµÄ±í¡£
* Key£¨¼üÖµ£© – ÉÏÃæHashģʽµÄÒ»ÖÖÑÓÉ죬ÕâÀïµÄHash KeyÊÇMySQLϵͳ²úÉúµÄ¡£
* List£¨Ô¤¶¨ÒåÁÐ±í£© – ÕâÖÖģʽÔÊÐíϵͳͨ¹ýDBA¶¨ÒåµÄÁбíµÄÖµËù¶ÔÓ¦µÄÐÐÊý¾Ý½øÐзָÀýÈ磺DBA½¨Á¢ÁËÒ»¸öºá¿çÈý¸ö·ÖÇøµÄ±í£¬·Ö±ð¸ù¾Ý2004Äê2005ÄêºÍ2006ÄêÖµËù¶ÔÓ¦µÄÊý¾Ý¡£
* Composite£¨¸´ºÏģʽ£© - ºÜÉñÃØ°É£¬¹þ¹þ£¬ÆäʵÊÇÒÔÉÏģʽµÄ ......
MySQL³£ÓÃÃüÁî×ܽá
===MySQL»ù´¡====
mysqlÏÂÔØ: http://www.mysql.com/
mysqld ³£¹æMySQL·þÎñÆ÷
mysqld-opt ÓÅ»¯mysql·þÎñÆ÷,ÌṩһЩ¹¦ÄÜ¿ÉÒÔÍÚ¾ò¸üºÃµÄ¹¦ÄÜ
mysqld-max ÓëmysqldÒ»Ñù,µ«¿ÉÒÔÖ§³Ö¸üÐÂ,¸ü¾ßʵÑéÐÔÖʵŦÄÜ(¸ü²»Îȶ¨)
++°²×°mysql
²Î¼û×Ô´øµÄINSTALL-SOURCEÎļþ
$ ./configure –prefix=/app/mysql-5.0.51a –with-charset=utf8 –with-extra-charsets=gbk,gb2312,utf8
++Æô¶¯/¹Ø±Õmysql
$ path/mysqld_safe -user=mysql &
$ /mysqladmin -p shutdown
++ÐÞ¸Äroot¿ÚÁî
$ mysqladmin -u root -p password ‘ÐÂÃÜÂë’
++²é¿´·þÎñÆ÷״̬
$ path/mysqladmin version -p
++Á¬½ÓÔ¶¶Ëmysql·þÎñÆ÷
$ path/mysql -u Óû§Ãû -p #Á¬½Ó±¾»ú
$ path/mysql -h Ô¶³ÌÖ÷»úIP -u Óû§Ãû -p#Á¬½ÓÔ¶³ÌMYSQL·þÎñÆ÷
++´´½¨/ɾ³ý Êý¾Ý¿â»ò±í
$ mysqladmin -u root -p create xxx
mysql> create database Êý¾Ý¿âÃû;
mysql> create TABLE items (
id INT(5) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
symbol CHAR(4) NOT NULL,
username CHAR(8),
INDEX sym (symbol),INDEX …..
UNIQUE(username)
) type=innodb;
m ......
ÎÒ±¾»ú²âÊÔÊÇ°²×°µÄ mysql 5.1 , µ« centos ·þÎñÆ÷ÉÏÈ·ÊÇʹÓÃµÄ mysql 5.0 , ƽʱû·¢ÏÖ²î±ð, µ«×î½üsql Îļþµ¼Èëµ¼³öʱ·¢ÏÖÁË, Ò»µãСС²î±ð.
Ö÷ÒªÊÇÔÚ´¦Àíµ½Ë÷ÒýÓï¾äʱ³öÏÖÁ˲»¼æÈݵÄÇé¿ö, ±ÈÈçÏÂÃæÓï¾äÊÇÔÚ mysql 5.1 µ¼³öµÄ:
KEY `index_2` (`datatype`,`stime`,`line`,`mcode`) USING BTREE
Èç¹ûÏëµ¼Èëµ½ mysql 5.0 Ôòµ÷Õû USING BTREE ÕâÀàÖ¸¶¨Ë÷ÒýÀàÐÍÓï¾äµÄλÖõ½Öмä, Ϊ:
KEY `index_2` USING BTREE (`datatype`,`stime`,`line`,`mcode`)
......
Ò»¡¢MySQL°²×°£º
Ìí¼ÓϵͳÓû§£º
groupadd mysql (/usr/sbin/groupadd)
useradd -g mysql mysql
°²×°²½Ö裺
tar zxfv mysql-*.tar.gz(mysql-5.0.51a)
./configure --prefix=/usr/local/mysql
make
make install
cp support-files/my-medium.cnf /etc/my.cnf
cd /usr/local/mysql
bin/mysql_install_db --user=mysql
chown -R root .
chown -R mysql var
chgrp -R mysql .
Æô¶¯·þÎñÃüÁ
/usr/local/mysql/bin/mysqld_safe &
¶þ¡¢µÇ¼MySQL
µÇ¼MySQLµÄÃüÁîÊÇmysql£¬ mysql µÄʹÓÃÓï·¨ÈçÏ£º
mysql [-u username] [-h host] [-p[password]] [dbname]
username Óë password ·Ö±ðÊÇ MySQL µÄÓû§ÃûÓëÃÜÂ룬mysqlµÄ³õʼ¹ÜÀíÕʺÅÊÇroot£¬Ã»ÓÐÃÜÂ룬עÒ⣺Õâ¸örootÓû§²»ÊÇLinuxµÄϵͳÓû§¡£MySQLĬÈÏÓû§ÊÇroot£¬ÓÉÓÚ³õʼûÓÐÃÜÂ룬µÚÒ»´Î½øʱֻÐè¼üÈëmysql¼´¿É¡£
[root@test1 local]# mysql
Welcome to the MySQL monitor.¡¡Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.0.16-standard
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
³öÏÖÁË“mysql>”Ìáʾ·û£¬¹ ......