mysqlÃüÁî_»ù´¡
ÏÔʾmysql»ù±¾ÐÅÏ¢£ºmysql>status;
²é¿´±äÁ¿£ºshow variables like '%version%';
±¸·ÝÓ뻹ÔÃüÁÔÚ×îºó»¹ÓÐ
1.±¸·ÝMySQLÊý¾Ý¿âµÄÃüÁî:
ÔÚcmdÖнøÈëµ½mysqlµÄlibĿ¼ÏÂÖ´ÐÐÈçÏ£º
mysqldump -hhostname -uusername -ppassword databaseName > backupfile.sql
Àý£ºmysqldump -hlocalhost -uroot -p123456 test > test.sql
2.µ¼³öÒ»¸ö±í£º
mysqldump -u Óû§Ãû -p Êý¾Ý¿âÃû ±íÃû> µ¼³öµÄÎļþÃû
mysqldump -u root -p dataname users> dataname_users.sql
»¹ÔMySQLÊý¾Ý¿âµÄÃüÁ
Ê×ÏÈн¨Ò»¸öÊý¾Ý¿â£ºcreate database Êý¾Ý¿â;
È»ºó½øÈëÊý¾Ý¿â£ºuse Êý¾Ý¿âÃû;
È»ºóÖ´ÐÐsql½Å±¾£ºmysql>source d:\aaa.sql;
Íê³É
°ïÖúÃüÁ½øÈëlibĿ¼ÏÂmysqldump -help
×¢£ºÈç¹ûÅäÖÃÁË»·¾³±äÁ¿¾Í²»ÓýøÈëlibϾͿÉÒÔÖ±½ÓÔËÐÐ
Á¬½ÓMySQL
ÏÈÖ´ÐÐmysql°²×°Ä¿Â¼ÏµÄmysqld.exeÆô¶¯·þÎñ
½øÈëMySQL¹ÜÀí½çÃæ
mysql -h localhost -u root -p
-h Ö÷»úÃû -uÓû§Ãû -p ÃÜÂë
ÐÞ¸ÄÃÜÂë¡£
¸ñʽ£ºmysqladmin -uÓû§Ãû -p¾ÉÃÜÂë password ÐÂÃÜÂë
mysqladmin -u root -password ab12
×¢£ºÒòΪ¿ªÊ¼Ê±rootûÓÐÃÜÂ룬ËùÒÔ-p¾ÉÃÜÂëÒ»Ïî¾Í¿ÉÒÔÊ¡ÂÔÁË¡£
ÔÙ½«rootµÄÃÜÂë¸ÄΪ123456¡£
ÏÔʾËùÓÐÊý¾Ý¿â
show databases;
½¨Á¢Ò»¸öпâ
create database new;
drop database if exists school; //Èç¹û´æÔÚSCHOOLÔòɾ³ý
ʹÓÃÕâ¸öÊý¾Ý¿â
use new;
½¨Á¢Ð±í
create table app_user(
username varchar(20),
password varchar(255),
primary key(username));
ÏÔʾ±í½á¹¹
describe app_user;/desc app_user;
ÏÔʾËùÓбí
show tables;
²åÈë²âÊÔÊý¾Ý
insert into app_user values('tomcat' , '123');
insert into app_user values('yeeku' , '123');
Í˳öMySQL¹ÜÀí½çÃæ
exit/quit;
Ïà¹ØÎĵµ£º
1016´íÎó£ºÎļþÎÞ·¨´ò¿ª£¬Ê¹Óúǫ́ÐÞ¸´»òÕßʹÓÃphpmyadmin½øÐÐÐÞ¸´¡£
1044´íÎó£ºÊý¾Ý¿âÓû§È¨ÏÞ²»×㣬ÇëÁªÏµ¿Õ¼äÉ̽â¾ö
1045´íÎó£ºÊý¾Ý¿â·þÎñÆ÷/Êý¾Ý¿âÓû§Ãû/Êý¾Ý¿âÃû/Êý¾Ý¿âÃÜÂë´íÎó£¬ÇëÁªÏµ¿Õ¼äÉ̼ì²éÕÊ»§¡£
1054´íÎ󣺳ÌÐòÎļþ¸úÊý¾Ý¿âÓгåÍ»£¬ÇëʹÓÃÕýÈ·µÄ³ÌÐòÎļþÉÏ´«ÉÏÈ¥¸²¸Ç¡£
1146´íÎó£ºÊý¾Ý±íȱʧ,Çë»Ö ......
±¸·ÝMySQLÊý¾Ý¿âµÄÃüÁî
mysqldump -hhostname -uusername -ppassword databasename > backupfile.sql
±¸·ÝMySQLÊý¾Ý¿âΪ´øÉ¾³ý±íµÄ¸ñʽ
±¸·ÝMySQLÊý¾Ý¿âΪ´øÉ¾³ý±íµÄ¸ñʽ£¬Äܹ»Èøñ¸·Ý¸²¸ÇÒÑÓÐÊý¾Ý¿â¶ø²»ÐèÒªÊÖ¶¯É¾³ýÔÓÐÊý¾Ý¿â¡£
mysqldump -–add-drop-table -uusername -ppassword databasename > backu ......
mysqlÓÐÒ»¸ö¹¦ÄܾÍÊÇ¿ÉÒÔlogÏÂÀ´ÔËÐеıȽÏÂýµÄsqlÓï¾ä£¬Ä¬ÈÏÊÇûÓÐÕâ¸ölogµÄ£¬ÎªÁË¿ªÆôÕâ¸ö¹¦ÄÜ£¬
ÒªÐÞ¸Ämy.cnf»òÕßÔÚmysqlÆô¶¯µÄʱºò¼ÓÈëһЩ²ÎÊý¡£Èç¹ûÔÚmy.cnfÀïÃæÐ޸ģ¬ÐèÔö¼ÓÈçϼ¸ÐÐ
long_query_time = 1
log-slow-queries = /var/youpath/slow.log
log-queries-not-using-indexes
long_query_time ÊÇÖ¸Ö´ ......
¡¡ÍøÉÏÓкܶàµÄÎÄÕ½ÌÔõôÅäÖÃMySQL·þÎñÆ÷£¬µ«¿¼Âǵ½·þÎñÆ÷Ó²¼þÅäÖõIJ»Í¬£¬¾ßÌåÓ¦ÓõIJî±ð£¬ÄÇЩÎÄÕµÄ×ö·¨Ö»ÄÜ×÷Ϊ³õ²½ÉèÖòο¼£¬ÎÒÃÇÐèÒª¸ù¾Ý×Ô¼ºµÄÇé¿ö½øÐÐÅäÖÃÓÅ»¯£¬ºÃµÄ×ö·¨ÊÇMySQL·þÎñÆ÷Îȶ¨ÔËÐÐÁËÒ»¶Îʱ¼äºóÔËÐУ¬¸ù¾Ý·þÎñÆ÷µÄ”״̬”½øÐÐÓÅ»¯¡£
mysql> show global status;
¡¡¡¡¿ÉÒÔÁгöMySQL·þÎ ......
ÏÂÎç¿´ÁËÒ»¶ÎPHP100µÄÊÓÆµ¡£
Ò²ËãÓеãÊÕ»ñ¡£
ÀïÃæµÄÒ»¶Î×ÔдµÄfindallµÄSQLº¯Êý£º
public function findall($table) {
$this->query("SELECT * from $table");
}
ÔÀ´Ö»ÊÇÕâô¼òµ¥£¬¸Õ»¹ÔÚ˼¿¼¡£
ʹÓÃÁËTAB¼üÉÏÃæµÄ¶ÙºÅÀ´ÐÞÊÎMYSQLÀïµÄ×Ö¶ÎÃû£¬È磺
UPDATE tablename SET `fieldname`='values' wh ......