Ò»¡¢ÏÂÔØMySQL
¹Ù·½ÍøÕ¾£ºwww.mysql.org
¶þ¡¢°²×°
1.½«´ËѹËõ°ü½âѹËõµ½Öƶ¨Îļþ¼ÐÏ£¬ÒÔ"C:/mysql"ΪÀý
2.½«my-midium.ini¸´ÖÆÒ»·Ý£¬²¢ÖØÃüÃûΪmy.ini
3.½«C:/mysql/bin/libmysql.dll¸´ÖƵ½ÏµÍ³Ä¿Â¼Ï£¬ÀýÈ縴ÖƵ½"C:/windows"ÏÂ
4.ÔÚÃüÁîÐÐģʽÏ£¬ÔËÐÐC:/mysql/bin/mysqld£¬¼´¿É¿ªÆôMySQL·þÎñÆ÷µÄÊØ»¤¹ý³Ì£¬Èç¹û¹Ø±Õ£¬¿É½øÈëC:/mysql/binÏ£¬ÊäÈ룺
mysql admin -u root -p shutdown(rootÓÐÃÜÂë)
mysql admin -u root shutdown(rootÎÞÃÜÂë)
ÐÞ¸ÄrootÃÜÂ룺
£¨Ò»£©Ã»ÃÜÂëʱ
1.¿ªÆôÊØ»¤½ø³Ì£¬¼´ÔËÐÐ"C:/mysql/bin/mysql"
2.ÔÚÃüÁîÐÐģʽÏ£¬½øÈë"C:/mysql/bin"Ŀ¼£¬ÊäÈ룺mysqladmin -u root password 'your password'
ÆäÖÐ'your password'ΪÄãÒªÉ趨µÄÃÜÂë
£¨¶þ£©ÓÐÃÜÂëʱ
1.ÔÚÃüÁîÐÐģʽÏ£¬½øÈë"C:/mysql/bin"Ŀ¼£¬ÊäÈ루¿ªÆôÊØ»¤½ø³Ì£©£ºmysqld --skip -grant -tables
2.ÊäÈ룺mysql ½øÈëmysqlÃüÁîÐУ¬Ìáʾ·ûΪ"mysql>"
3.ÊäÈ룺
use mysql
......
WordpressÓÃÁËÕâô³¤Ê±¼ä£¬Å¼¶û»áÏëÆðÀ´±¸·ÝÏÂÊý¾Ý£¬ÉÏ´ÎÊÇÓÃwpµÄxml£¬Õâ´Î°Ñ×Ô¼º»úÆ÷µÄ»·¾³ÅäµÄ¸úÖ÷»úÌṩÉÌ»ù±¾Ò»ÑùÁË£¬ÕýºÃÄDZßÓÐmysqlÊý¾Ý¿â´ò°ü±¸·ÝµÄ·þÎñ£¬¾Í³¢ÊÔÁËһϡ£¿É²»¹ÜÎÒÏÂÔØÄĸöʱ¼äµãµÄ±¸·Ý°ü£¬ÀïÃ涼ֻÓÐwp±íµÄ10¸öfrmÎļþ£¬copyµ½ÎÒµÄÊý¾Ý¿âĿ¼ºó·ÃÎÊweb£¬Ã»ÓÐÈκÎÊý¾Ý£¡Ö±½Ó¸ã²»¶®ÁË¡£ÒÔÇ°¾õµÃÓÃmysql×î´óµÄ·½±ã¾ÍÊÇÊý¾Ý¿âÎļþ¿ÉÒÔÖ±½Ó¸´ÖÆÕ³Ìù£¬ºóÀ´¾ÍÍƼöÖÜΧµÄÈ˶¼Ó᣿ÉÕâô³¤Ê±¼äÎÒ²¢Ã»ÓÐÈ¥×ÐϸÑо¿Õâ¸ö¹ãÊܺÃÆÀµÄ²úÆ·£¬ÎÒ¼¸ºõ²»×öºó¶Ë¿ª·¢£¬¿ÉÒÔ˵ʹÓõÄÇé¿ö¶¼²»¶à¡£ÓÚÊÇÕâ´Îcopy±íûЧ¹û£¬ÍêÈ«²»ÖªµÀΪʲô¡£
ËìÓëСÁ¦ÌÖÂÛ£¬ËûÒ²¾õµÃÆæ¹Ö¡£¶øÇÒËû¸úÎÒÓõÄÒ»¸ö·þÎñÉÌ£¬Æ½³£Ëû±¸·Ý´ÓÀ´Ã»Óöµ½¹ýʲôÎÊÌâ¡£ÓÚÊÇÈÃËûÏÂÒ»·ÝËûÊý¾Ý¿âµÄ±¸·Ý¸øÎҶԱȣ¬´ò¿ªrar°ü£¬±ÈÎÒµÄwp¶à´¦N¸öÎļþ£¡×Ðϸ¿´£¬Ò²¶¼ÊÇwpµÄ±íÃû£¬µ«ÊÇÿ¸ö±íÃû¶ÔÓ¦3¸öÎļþ£º.frm£¬.myd£¬.myi¡£ÎÊÌâ¾Í³öÔÚÕâÀïÁË£¬´Ó×ÖÃæ¿´³ö£¬frmÊDZí½á¹¹£¬mydÊÇmysqlÊý¾ÝÎļþ£¬myiÓ¦¸ÃÊÇË÷Òý°É¡£¶øÎÒ±¸·ÝµÄÊý¾Ý¿âÖ»ÓÐ10¸ö±íµÄfrm½á¹¹£¬µ±È»¿´²»µ½Êý¾ÝÁË£¡
ºÜÓôÃÆ£¬ÎªÊ²Ã´Í¬Ò»¸ö·þÎñÉÌÎÒµÄÊý¾Ý¿â¾ÍÎļþ²»È«£¿ÎÊÌâÎÒÍøÕ¾ÉϵÄÊý¾ÝÊÇÓеİ¡£¡ÔÝʱû°ì·¨£¬È¥ÕÒ·þÎñÉÌ×Éѯ£¬ÓÚÊÇËû°ÑÎÒÃèÊöµÄÎÊÌâÑéÖ¤ÁË£¬²¢ÔÙ´Î ......
[Ó²¼þÅäÖÃ]
CPU : AMD2500+ (1.8G)
ÄÚ´æ: 1G/ÏÖ´ú
Ó²ÅÌ: 80G/IDE
[Èí¼þÅäÖÃ]
OS : Windows XP SP2
SE : PHP5.2.1
DB : MySQL5.0.37
Web: IIS6
[MySQL±í½á¹¹]
CREATE TABLE `myisam` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(100) default NULL,
`content` text,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=gbk;
CREATE TABLE `innodb` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(100) default NULL,
`content` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=gbk;
[Êý¾ÝÄÚÈÝ]
$name = "heiyeluren";
$content = "MySQLÖ§³ÖÊý¸ö´æ´¢ÒýÇæ×÷Ϊ¶Ô²»Í¬±íµÄÀàÐ͵Ĵ¦ÀíÆ÷¡£MySQL´æ´¢ÒýÇæ°üÀ¨´¦ÀíÊÂÎñ°²È«±íµÄÒýÇæºÍ´¦Àí·ÇÊÂÎñ°²È«±íµÄÒýÇ棺· MyISAM¹ÜÀí·ÇÊÂÎñ±í¡£ËüÌṩ¸ßËÙ´æ´¢ºÍ¼ìË÷£¬ÒÔ¼°È«ÎÄËÑË÷ÄÜÁ¦¡£MyISAMÔÚËùÓÐMySQLÅäÖÃÀï±»Ö§³Ö£¬ËüÊÇĬÈϵĴ洢ÒýÇ棬³ý·ÇÄãÅäÖÃMySQLĬÈÏʹÓÃÁíÍâÒ»¸öÒýÇæ¡£ ·MEMORY´æ´¢ÒýÇæÌṩ“ÄÚ´æÖД±í¡£MERGE´æ´¢ÒýÇæÔÊÐí¼¯ºÏ½«±»´¦ÀíͬÑùµÄMyISAM±í×÷Ϊһ¸öµ¥¶ÀµÄ± ......
20 MySQL¿Í»§¹¤¾ßºÍAPI
20.1 MySQL C API
C API´úÂëÊÇËæMySQL·Ö·¢µÄ£¬Ëü±»°üº¬ÔÚmysqlclient¿âÇÒÔÊÐíC³ÌÐò´æÈ¡Ò»¸öÊý¾Ý¿â¡£
ÔÚ MySQLÔ´´úÂë·Ö·¢Öеĺܶà¿Í»§ÊÇÓÃC±àдµÄ¡£Èç¹ûÄãÕýÔÚÑ°ÕÒÑÝʾÔõÑùʹÓÃC APIµÄÀý×Ó£¬¿´Ò»ÏÂÕâЩ¿Í»§³ÌÐò¡£
´ó¶àÊýÆäËû¿Í»§ API(³ýÁËJavaµÄËùÓÐ)¶¼Ê¹ÓÃmysqlclient¿âÓëMySQL·þÎñÆ÷ͨÐÅ¡£ÕâÒâζ×Å£¬ÀýÈ磬ÄãÄÜÀûÓúܶ౻ÆäËû¿Í»§³ÌÐòʹÓõÄͬһ»·¾³±äÁ¿£¬ÒòΪËûÃÇ´Ó¿âÖÐÒýÓ᣶ÔÕâЩ±äÁ¿µÄÒ»ÕÅ±í£¬¼û12.1 ²»Í¬µÄMySQL³ÌÐòµÄ¸ÅÊö¡£
¿Í»§ÓÐÒ»¸ö×î´óͨѶ»º³åÇø´óС¡£³õʼ·ÖÅäµÄ»º³åÇø´óС(16K×Ö½Ú) ×Ô¶¯µØÔö¼Óµ½×î´ó³ß´ç(ȱʡµÄ×î´óÖµÊÇ24M)¡£ÒòΪ»º³åÇø´óСֻÊÇ°´±£Ö¤ÐèÇó¶ø±»Ôö¼Ó£¬¼òµ¥µØÔö¼ÓȱʡµÄ×î´óÏÞÖƲ¢²»Ôì³É¸ü¶à±»ÏûºÄ¡£¸Ã³ß´ç¼ì²éÖ÷ÒªÊÇÒ»¸ö¶Ô´íÎóµÄ²éѯºÍͨѶ°üµÄ¼ì²é¡£
ͨѶ»º³åÇø±ØÐë×ã¹»´óÒÔ±ãÒ»¸öµ¥¶ÀµÄSQLÓï¾ä(¶Ô¿Í»§-·þÎñÆ÷´«Êä)ºÍÒ»Ðзµ»ØµÄÊý¾Ý(¶Ô·þÎñÆ÷-¿Í»§´«Êä)¡£Ã¿¸öÏ̵߳ÄͨѶ»º³åÇø±»¶¯Ì¬À©´óµ½×î´óÏÞÖÆÀ´´¦ÀíÈκβéѯ»òÐС£ÀýÈ磬Èç¹ûÄã°üº¬´óµ½16MÊý¾ÝµÄBLOBÖµ£¬Äã±ØÐëÓÐÒ»¸öÖÁÉÙ16MͨѶ»º³åÇøÏÞÖÆ(ÔÚ·þÎñÆ÷ºÍ¿Í»§Á½¶Ë)¡£¿Í»§µÄȱʡ×î´óÖµÊÇ24M£¬µ«ÊÇÔÚ·þÎñÆ÷¶ËµÄȱʡ×î´óÖµÊÇ1M¡£Äã¿ÉÒÔÔÚ·þÎñÆ÷Æô¶¯Ê±Í¨¹ý¸Ä ......
MySQL :: Linux ÏÂ×Ô¶¯±¸·ÝÊý¾Ý¿âµÄ shell ½Å±¾
Linux ·þÎñÆ÷ÉϵijÌÐòÿÌ춼ÔÚ¸üРMySQL Êý¾Ý¿â£¬ÓÚÊǾÍÏëÆðдһ¸ö shell ½Å±¾£¬½áºÏ crontab£¬¶¨Ê±±¸·ÝÊý¾Ý¿â¡£Æäʵ·Ç³£¼òµ¥£¬Ö÷Òª¾ÍÊÇʹÓà MySQL ×Ô´øµÄ mysqldump ÃüÁî¡£
½Å±¾ÄÚÈÝÈçÏ£º
#!/bin/sh
# File: /home/mysql/backup.sh
# Database info
DB_NAME="test"
DB_USER="username"
DB_PASS="password"
# Others vars
BIN_DIR="/usr/local/mysql/bin"
BCK_DIR="/home/mysql/backup"
DATE=`date +%F`
# TODO
$BIN_DIR/mysqldump --opt -u$DB_USER -p$DB_PASS $DB_NAME | gzip > $BCK_DIR/db_$DATE.gz
È»ºóʹÓý«´Ë½Å±¾¼Óµ½ /etc/crontab ¶¨Ê±ÈÎÎñÖУº
01 5 * * 0 mysql /home/mysql/backup.sh
ºÃÁË£¬Ã¿ÖÜÈÕÁ賿 5:01 ϵͳ¾Í»á×Ô¶¯ÔËÐÐ backup.sh Îļþ±¸·Ý MySQL Êý¾Ý¿âÁË¡£
/home/www/inc/back ......
MySQL :: Linux ÏÂ×Ô¶¯±¸·ÝÊý¾Ý¿âµÄ shell ½Å±¾
Linux ·þÎñÆ÷ÉϵijÌÐòÿÌ춼ÔÚ¸üРMySQL Êý¾Ý¿â£¬ÓÚÊǾÍÏëÆðдһ¸ö shell ½Å±¾£¬½áºÏ crontab£¬¶¨Ê±±¸·ÝÊý¾Ý¿â¡£Æäʵ·Ç³£¼òµ¥£¬Ö÷Òª¾ÍÊÇʹÓà MySQL ×Ô´øµÄ mysqldump ÃüÁî¡£
½Å±¾ÄÚÈÝÈçÏ£º
#!/bin/sh
# File: /home/mysql/backup.sh
# Database info
DB_NAME="test"
DB_USER="username"
DB_PASS="password"
# Others vars
BIN_DIR="/usr/local/mysql/bin"
BCK_DIR="/home/mysql/backup"
DATE=`date +%F`
# TODO
$BIN_DIR/mysqldump --opt -u$DB_USER -p$DB_PASS $DB_NAME | gzip > $BCK_DIR/db_$DATE.gz
È»ºóʹÓý«´Ë½Å±¾¼Óµ½ /etc/crontab ¶¨Ê±ÈÎÎñÖУº
01 5 * * 0 mysql /home/mysql/backup.sh
ºÃÁË£¬Ã¿ÖÜÈÕÁ賿 5:01 ϵͳ¾Í»á×Ô¶¯ÔËÐÐ backup.sh Îļþ±¸·Ý MySQL Êý¾Ý¿âÁË¡£
/home/www/inc/back ......
mysql Æ𶯴íÎó½â¾ö°ì·¨- -
Access denied for user ''@'localhost' to database 'mysql'
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'
µÚÒ»´Î°²×°ÔËÐÐÒÔÏÂÒ»¾ä£¬²úÉúÊý¾Ý¿âÎļþ
/usr/local/bin/mysql_install_db
chown -R mysql /var/db/mysql
Æô¶¯mysql
/usr/local/bin/mysqld_safe &
mysql Æ𶯴íÎó½â¾ö°ì·¨- -
Access denied for user ''@'localhost' to database 'mysql'
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'
µÚÒ»´Î°²×°ÔËÐÐÒÔÏÂÒ»¾ä£¬²úÉúÊý¾Ý¿âÎļ ......