Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

C# mysql¶ÁÈ¡Àà

 using System;
using System.Data;
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 MySql.Data.Types;
using MySql.Data.MySqlClient;
/// <summary>
/// C#²Ù×÷mysql»ùÀà
/// </summary>
public class MySqlobj
{
private MySqlConnection conn;
private MySqlCommand com;
private bool _alreadyDispose = false;
#region ¹¹ÔìÓëèع¹
public MySqlobj()
{
try
{
conn = new MySqlConnection(ConfigurationManager.AppSettings["mysqlconn"]);
conn.Open();
com = new MySqlCommand();
com.Connection = conn;
}
catch (Exception ee)
{
throw new Exception("Á¬½ÓÊý¾Ý¿â³ö´í");
}
}
~MySqlobj()
{
Dispose();
}
protected virtual void Dispose(bool isDisposing)
{
if (_alreadyDispose) return;
if (isDisposing)
{
// TODO: ´Ë´¦ÊÍ·ÅÊÜ¿Ø×ÊÔ´
if (com != null)
{

com.Dispose();
}
if (conn != null)
{
try
{
conn.Close();
conn.Dispose();
}
catch (Exception ee)
{
}
finally
{
conn = null;
}
}
}
// TODO: ´Ë´¦ÊÍ·Å·ÇÊÜ¿Ø×ÊÔ´¡£ÉèÖñ»´¦Àí¹ý±ê¼Ç
_alreadyDispose = true;
}
#endregion
#region IDisposable ³ÉÔ±
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
#endregion
#region »ñÈ¡DataSet
public DataSet GetDataSet(string sqlString)
{
DataSet ds = new DataSet();
try


Ïà¹ØÎĵµ£º

mysql ÕÒ»ØÃÜÂë

 
1.  Í£µ½ÔËÐеÄmysql:    /etc/init.d/mysql stop
2.  ʹÓÃskip-grant-tablesÕâ¸öÑ¡ÏîÆô¶¯MySQL£º  /usr/bin/mysqld_safe --skip-grant-tables &
3.  ÏÖÔÚ¿ÉÒÔ²»ÓÃÃÜÂë½øÈëmysql ÁË¡£
     #  myql
    >   ......

MySQLÊý¾Ý¿â±¸·ÝºÍ»¹Ô­µÄ³£ÓÃÃüÁî

±¸·ÝMySQLÊý¾Ý¿âµÄÃüÁî
mysqldump -hhostname -uusername -ppassword databasename > backupfile.sql
±¸·ÝMySQLÊý¾Ý¿âΪ´øɾ³ý±íµÄ¸ñʽ
±¸·ÝMySQLÊý¾Ý¿âΪ´øɾ³ý±íµÄ¸ñʽ£¬Äܹ»Èøñ¸·Ý¸²¸ÇÒÑÓÐÊý¾Ý¿â¶ø²»ÐèÒªÊÖ¶¯É¾³ýÔ­ÓÐÊý¾Ý¿â¡£
mysqldump -–add-drop-table -uusername -ppassword databasename > backu ......

MySQLÖÐÎÄÂÒÂëÎÊÌâ½âÎö

Ê×ÏÈ·ÖÎöÂÒÂëµÄÇé¿ö
1.дÈëÊý¾Ý¿âʱ×÷ΪÂÒÂëдÈë
2.²éѯ½á¹ûÒÔÂÒÂë·µ»Ø
¾¿¾¹ÔÚ·¢ÉúÂÒÂëʱÊÇÄÄÒ»ÖÖÇé¿öÄØ£¿
ÎÒÃÇÏÈÔÚmysql ÃüÁîÐÐÏÂÊäÈë
show variables like '%char%';
²é¿´mysql ×Ö·û¼¯ÉèÖÃÇé¿ö:
mysql> show variables like '%char%';
+--------------------------+---------------------------------------- ......

MySQLµ¼³öµ¼ÈëÃüÁîµÄÓÃÀý

¡¡1.µ¼³öÕû¸öÊý¾Ý¿â
¡¡¡¡mysqldump -u Óû§Ãû -p Êý¾Ý¿âÃû > µ¼³öµÄÎļþÃû
¡¡¡¡mysqldump -u wcnc -p smgp_apps_wcnc > wcnc.sql
¡¡¡¡2.µ¼³öÒ»¸ö±í
¡¡¡¡mysqldump -u Óû§Ãû -p Êý¾Ý¿âÃû ±íÃû> µ¼³öµÄÎļþÃû
¡¡¡¡mysqldump -u wcnc -p smgp_apps_wcnc users> wcnc_users.sql
¡¡¡¡3.µ¼³öÒ»¸öÊý¾Ý¿â½á¹¹
¡ ......

JDBCÁ¬½ÓÖ´ÐÐMySQL´æ´¢¹ý³Ì±¨¿ÕÖ¸Õë»òȨÏÞ´íÎó

 ×î½üʹÓÃrootÓû§±àдÁ˼¸¸ö´æ´¢¹ý³Ì£¬µ«ÊÇʹÓÃÆÕͨÓû§Í¨¹ýJDBCÁ¬½ÓÖ´ÐÐÈ´±¨´í£º
java.lang.NullPointerException......
»ò
java.sql.SQLException: User does not have access to metadata required to determine stored procedure parameter types. If rights can not be granted, configure connection with " ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ