MySQL°²×°Ö¸ÄÏ
MySQL°²×°Ö¸ÄÏ
Òª°²×° MySQL£¬¿ÉÒÔÔÚÖÕ¶ËÌáʾ·ûºóÔËÐÐÏÂÁÐÃüÁ
sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get install php5-mysql
// °²×°php5-mysql Êǽ«phpºÍmysqlÁ¬½ÓÆðÀ´
Ò»µ©°²×°Íê³É£¬MySQL ·þÎñÆ÷Ó¦¸Ã×Ô¶¯Æô¶¯¡£Äú¿ÉÒÔÔÚÖÕ¶ËÌáʾ·ûºóÔËÐÐÒÔÏÂÃüÁîÀ´¼ì²é MySQL ·þÎñÆ÷ÊÇ·ñÕýÔÚÔËÐУº
sudo netstat -tap | grep mysql
µ±ÄúÔËÐиÃÃüÁîʱ£¬Äú¿ÉÒÔ¿´µ½ÀàËÆÏÂÃæµÄÐУº
tcp 0 0 localhost.localdomain:mysql *:* LISTEN -
Èç¹û·þÎñÆ÷²»ÄÜÕý³£ÔËÐУ¬Äú¿ÉÒÔͨ¹ýÏÂÁÐÃüÁîÆô¶¯Ëü£º
sudo /etc/init.d/mysql restart
½øÈëmysql
mysql -uroot -p
(ÊäÈëmysqlµÄrootÃÜÂë)
ÅäÖà MySQL µÄ¹ÜÀíÔ±ÃÜÂ룺
sudo mysqladmin -u root password newpassword
Ïà¹ØÎĵµ£º
MySQLÓÐÒ»¸ö¹¦ÄܾÍÊÇ¿ÉÒÔlogÏÂÀ´ÔËÐеıȽÏÂýµÄsqlÓï¾ä£¬Ä¬ÈÏÊÇûÓÐÕâ¸ölogµÄ£¬ÎªÁË¿ªÆôÕâ¸ö¹¦ÄÜ£¬ÒªÐÞ¸Ämy.cnf»òÕßÔÚMySQLÆô¶¯µÄʱºò¼ÓÈëһЩ²ÎÊý¡£
Èç¹ûÔÚmy.cnfÀïÃæÐ޸ģ¬ÐèÔö¼ÓÈçϼ¸ÐÐ
long_query_time = 1
log-slow-queries =
log-queries-not-using-indexes
long_query_time ÊÇÖ¸Ö´Ðг¬¹ý¶à¾ÃµÄsql»á±»logÏÂÀ´£ ......
ʹÓÃhibernate mysql ²åÈëÖÐÎÄ´íÎó£º
ÔÒòÖ®Ò»ÊÇ£º
mysql µÄ×Ö·û±àÂëºÍhibernate´«µÝµÄ±àÂë²»Ò»Ñù£¬
ÀýÈ磺
mysql ½¨¿âµÄʱºò¿ÉÒÔÉèÖñàÂë:
CREATE DATABASE db DEFAULT CHARACTER SET utf8;
hibernate Á¬½ÓmysqlµÄ±àÂ룺
jdbc:mysql://127.0.0.1:3306/db?useU ......
(1)mysql_connect(Ö÷»ú,Óû§Ãû,¿ÚÁî);
·µ»ØÒ»¸öÁ¬½ÓºÅ.
×¢Òâ:mysql¸÷Óû§µÄ¿ÚÁî¿ÉÒÔËæ¸ÃÓû§ËùÔÚ»úÆ÷IPµØÖ·²»Í¬¶ø¸Ä±ä. ÁíÍâ,mSQLûÓÐÓû§Ãû»úÖÆ,ËùÒÔmsql_connectÖ»ÐèÒªÒ»¸öÖ÷»ú²ÎÊý.Ö÷»ú¿ÉÒÔÊÇIPµØÖ·»òÓòÃû.
(2)mysql_create_db(Êý¾Ý¿âÃû);
(3)mysql_select_db(Êý¾Ý¿âÃû,Á¬½ÓºÅ);
Á¬½ÓÒ»¸öÊý¾Ý¿â.
(4)mysql_q ......
mysqlÊý¾Ý¿â±¸·ÝÓ뻹ÔÃüÁ
±¸·Ý£º
ÈçÎÒÃÇÐèÒª°Ñ Êý¾Ý¿âÃûΪ£ºshopping µÄÊý¾Ý¿â±¸·Ý£º Óû§ÃûΪ£ºroot£¬ÃÜÂëΪ£º12345£¬ÄÇôÃüÁîÈçÏ£º
Ö±½Ó½øÈëdos£¬Èç¹ûûÓÐÅäÖÃmysqlµÄ»·¾³±äÁ¿£¬ÄÇôÐèÒª°ÑdosµÄµ±Ç°Ä¿Â¼Çл»µ½mysqlµÄbinĿ¼Ï£¬È»ºóÇÃÈëÒ»ÏÂÃüÁ
mysqldump -uroo ......
DROP PROCEDURE IF exists pro_removeBillRemindByUserId;
create procedure pro_removeBillRemindByUserId(userId int)
begin
declare ts varchar(500);
declare cnt int default 0;
declare f_ID,b int;
DECLARE cur_1 CURSOR ......