using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MySQLDriverCS;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
MySQLConnection conn = null;
conn = new MySQLConnection(new MySQLConnectionString("127.0.0.1", "Dvbbs", "root", "123456").AsString);
conn.Open();
MySQLCommand commn = new MySQLCommand("set names gb2312",conn);
commn.ExecuteNonQuery();
string ......
ÏÂÃæÊÇcommond:
MySQLCommand cmd;
cmd = new MySQLDriverCS.MySQLCommand("DROP TABLE IF EXISTS test.mysqldrivercs_test",conn);
cmd.ExecuteNonQuery();
cmd.Dispose();
ÏÂÃæÊÇinsert:
string Value = "Value";
int SettingID = 1;
new MySQLInsertCommand(conn,
new object[,] {{"SettingID",SettingID},{"SettingValue",Value}},
"mysqldrivercs_test");
ÏÂÃæÊÇupdate
Value = "Value2";
new MySQLUpdateCommand(conn,
new object[,] {{"SettingValue",Value}},
"mysqldrivercs_test",
new object[,] {{"SettingID","=",SettingID}},
null);
ÏÂÃæÊÇselect
DataTable dt = new MySQLSelectCommand(conn,
new string[] {"SettingID","SettingValue"},
new string[] {"mysqldrivercs_test"},
new object[,] {{"SettingID","=",SettingID}},
null,
null
).Table;
string storedValue = dt.Rows[0]["SettingValue"].ToString();
ÏÂÃæÊÇdelete
new MySQLDeleteCommand(conn,"mysqldrivercs_test",new object[,] {{"SettingID","=",SettingID}},null);
¹Ø±ÕÁ´½Ó:
conn.Close(); ......
ÏÂÃæÊÇcommond:
MySQLCommand cmd;
cmd = new MySQLDriverCS.MySQLCommand("DROP TABLE IF EXISTS test.mysqldrivercs_test",conn);
cmd.ExecuteNonQuery();
cmd.Dispose();
ÏÂÃæÊÇinsert:
string Value = "Value";
int SettingID = 1;
new MySQLInsertCommand(conn,
new object[,] {{"SettingID",SettingID},{"SettingValue",Value}},
"mysqldrivercs_test");
ÏÂÃæÊÇupdate
Value = "Value2";
new MySQLUpdateCommand(conn,
new object[,] {{"SettingValue",Value}},
"mysqldrivercs_test",
new object[,] {{"SettingID","=",SettingID}},
null);
ÏÂÃæÊÇselect
DataTable dt = new MySQLSelectCommand(conn,
new string[] {"SettingID","SettingValue"},
new string[] {"mysqldrivercs_test"},
new object[,] {{"SettingID","=",SettingID}},
null,
null
).Table;
string storedValue = dt.Rows[0]["SettingValue"].ToString();
ÏÂÃæÊÇdelete
new MySQLDeleteCommand(conn,"mysqldrivercs_test",new object[,] {{"SettingID","=",SettingID}},null);
¹Ø±ÕÁ´½Ó:
conn.Close(); ......
MysqlÊý¾Ý¿âÌṩÁ½ÖÖÀàÐ͵ÄË÷Òý£¬Èç¹ûûÕýÈ·ÉèÖã¬Ë÷ÒýµÄÀûÓÃЧÂÊ»á´ó´òÕÛ¿ÛÈ´ÍêÈ«²»ÖªÎÊÌâ³öÔÚÕâ¡£
CREATE TABLE test (
id INT NOT NULL,
last_name CHAR(30) NOT NULL,
first_name CHAR(30) NOT NULL,
PRIMARY KEY (id),
INDEX name (last_name,first_name)
);
ÒÔÉÏ´´½¨µÄÆäʵÊÇÒ»¸ö¶àÁÐË÷Òý£¬´´½¨ÁÐË÷ÒýµÄ´úÂëÈçÏ£º
CREATE TABLE test (
id INT NOT NULL,
last_name CHAR(30) NOT NULL,
first_name CHAR(30) NOT NULL,
PRIMARY KEY (id),
INDEX name (last_name),
INDEX_2 name (first_name)
);
Ò»¸ö¶àÁÐË÷Òý¿ÉÒÔÈÏΪÊÇ°üº¬Í¨¹ýºÏ²¢(concatenate)Ë÷ÒýÁÐÖµ´´½¨µÄÖµµÄÒ»¸öÅÅÐòÊý×é¡£ µ±²éѯÓï¾äµÄÌõ¼þÖаüº¬last_name ºÍ first_nameʱ£¬ÀýÈ磺
SELECT * from test WHERE last_name='Kun' AND first_name='Li';
sql»áÏȹýÂ˳ölast_name·ûºÏÌõ¼þµÄ¼Ç¼£¬ÔÚÆä»ù´¡ÉÏÔÚ¹ýÂËfirst_name·ûºÏÌõ¼þµÄ¼Ç¼¡£ÄÇÈç¹ûÎÒÃÇ·Ö±ðÔÚlast_nameºÍfirst_nameÉÏ´´½¨Á½¸öÁÐË÷Òý£¬mysqlµÄ´¦Àí·½Ê½¾Í²»Ò»ÑùÁË£¬Ëü»áÑ¡ÔñÒ»¸ö×îÑϸñµÄË÷ÒýÀ´½øÐмìË÷£¬¿ÉÒÔÀí½âΪ¼ìË÷ÄÜÁ¦×îÇ¿µÄÄǸöË÷ÒýÀ´¼ìË ......
ת×Ô:http://blog.chinaunix.net/u2/85344/showart_2042280.html
LiunxÏÂÐÞ¸ÄMySQL×Ö·û¼¯£º
1.²éÕÒMySQLµÄcnfÎļþµÄλÖÃ
find / -iname '*.cnf' -print
/usr/share/mysql/my-innodb-heavy-4G.cnf
/usr/share/mysql/my-large.cnf
/usr/share/mysql/my-small.cnf
/usr/share/mysql/my-medium.cnf
/usr/share/mysql/my-huge.cnf
/usr/share/texmf/web2c/texmf.cnf
/usr/share/texmf/web2c/mktex.cnf
/usr/share/texmf/web2c/fmtutil.cnf
/usr/share/texmf/tex/xmltex/xmltexfmtutil.cnf
/usr/share/texmf/tex/jadetex/jadefmtutil.cnf
/usr/share/doc/MySQL-server-community-5.1.22/my-innodb-heavy-4G.cnf
/usr/share/doc/MySQL-server-community-5.1.22/my-large.cnf
/usr/share/doc/MySQL-server-community-5.1.22/my-small.cnf
/usr/share/doc/MySQL-server-community-5.1.22/my-medium.cnf
/usr/share/doc/MySQL-server-community-5.1.22/my-huge.cnf
2. ¿½±´ small.cnf¡¢my-medium.cnf¡¢my-huge.cnf¡¢my-innodb-heavy-4G.cnfÆäÖеÄÒ»¸öµ½/etcÏ£¬ÃüÃûΪmy.cnf
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
3. ÐÞ¸Ämy.cnf
vi /etc/my.cnf
ÔÚ[ ......
mysql×Ö·û¼¯Ð£Ñé¹æÔò
mysql ²»Í¬ÓÚÆäËûÊý¾Ý¿â£¨Èçoracle£©£¬Ëü¿ÉÒÔÔÚ¶à¸ö¼¶±ðÉèÖÃ×Ö·û¼¯ºÍУÑé¹æÔò£¬Èçserver¼¶±ð¡¢database¼¶±ð¡¢table¼¶±ðºÍcolumn¼¶±ð¡£Êµ¼ÊÉÏ£¬ÎÒÃÇÉõÖÁ»¹¿ÉÒÔµ¥¶À¶ÔÒ»´®×Ö·û´®É趨Æä×Ö·û¼¯ºÍУÑé¹æÔò£¬»¹¿ÉÒÔÔÚÁ¬½ÓÖÐÉèÖÃÆä×Ö·û¼¯ºÍУÑé¹æÔò£¬ÏÂÃæÀ´¼òµ¥µÄÌÖÂÛÏÂÇ°4ÖÖ¼¶±ðµÄ×Ö·û¼¯ºÍУÑé¹æÔòµÄÉèÖá£
server
ÔÚÆô¶¯mysql·þÎñµÄʱºò£¬¿ÉÒÔÖ¸¶¨mysql serverµÄ×Ö·û¼¯ºÍУÑé¹æÔò£¬Í¨¹ýÈçÏ·½Ê½£º
mysqld --character-set-server=latin1 --collation-server=latin1_swedish_ci
Èç¹û²»Ç××ÔÖ¸¶¨ËüÃÇ£¬ÄÇômysql¾Í»áʹÓÃĬÈÏÖµ¡£Ò»°ãÊÇl ......
Êý¾Ý¿âĿ¼ÊÇMySQLÊý¾Ý¿â·þÎñÆ÷´æ·ÅÊý¾ÝÎļþµÄµØ·½£¬²»½ö°üÀ¨ÓйرíµÄÎļþ£¬»¹°üÀ¨Êý¾ÝÎļþºÍMySQLµÄ·þÎñÆ÷Ñ¡ÏîÎļþ¡£²»Í¬µÄ·Ö·¢£¬Êý¾Ý¿âĿ¼µÄȱʡλÖÃÊDz»Í¬µÄ¡£
Êý¾ÝĿ¼µÄλÖÃ
ȱʡµÄÊý¾Ý¿âλÖÃ
ȱʡÊý¾Ý¿âµÄλÖñàÒëÔÚ·þÎñÆ÷ÖС£
¡ôÈç¹ûÄúÊÇÔÚÒ»¸öÔ´³ÌÐò·Ö·¢°üÖа²×° MySQL£¬µäÐ͵ÄȱʡλÖÿÉÄÜÊÇ /usr/local/var£»
¡ôÈç¹ûÔÚ¶þ½øÖÆ·Ö·¢°üÖа²×° MySQL£¬ÔòΪ /usr/local/mysql/ data£»
¡ôÔÚ RPM ÎļþÖа²×°£¬Îª /var/lib/mysql¡£
¡ô¶ÔÓÚwindwosƽ̨Éϵķַ¢£¬ÆäλÖÃʱBASEDIR\data
Êý¾ÝĿ¼µÄλÖÿÉÒÔÔÚÆô¶¯·þÎñÆ÷ʱͨ¹ý--datadir = / path / to / dir Ã÷È·µØÖ¸¶¨¡£Èç¹ûÄúÏ뽫Êý¾ÝĿ¼·ÅÖÃÔÚÆäËûµØ·½¶ø·ÇȱʡµÄλÖã¬ÔòÕâ¸öÑ¡ÏîÊÇÓÐÓõġ£
Á˽âÊý¾Ý¿âĿ¼µÄλÖÃ
×÷ΪһÃû MySQL ¹ÜÀíÔ±£¬ÄúÓ¦¸ÃÖªµÀÊý¾ÝĿ¼ÔÚÄÄÀï¡£Èç¹ûÔËÐжà¸ö·þÎñÆ÷£¬ÄÇôÄúÓ¦¸ÃÕÆÎÕËùÓÐÊý¾ÝĿ¼µÄλÖᣵ«ÊÇ£¬Èç¹û²»ÖªµÀĿ¼µÄλÖ㨻òÐíÄúÕýÔÚ´úÌæǰһλ¹ÜÀíÔ±£¬¶øËûÁôϵļǼºÜÔã¸â£©£¬Óм¸ÖÖ·½·¨¿ÉÒÔÓÃÀ´²éÕÒËü£º
1¡¢¿ÉʹÓà mysqladmin ±äÁ¿Ö±½Ó´Ó·þÎñÆ÷Öеõ½Êý¾ÝĿ¼·¾¶Ãû¡£ÔÚ UNIX ÖУ¬Êä³ö½á¹ûÀàËÆÓÚÈçÏÂËùʾ£º
$mysqladmin variables
+-------------------------+------------ ......