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
Ïà¹ØÎĵµ£º
ʱ¼ä£º2009-03-12 12:38:24 À´Ô´£ºLinuxÁªÃË
×÷Õߣº
À´Ô´£ºit168.com
×÷ÕߣºÌïÒÝ(sery@163.com)
Ë×»°Ëµ£º¹¤ÓûÉÆÆäÊ£¬±ØÏÈÀûÆäÆ÷.Òª×öºÃϵͳ¹ÜÀí,ʹ×Ô¼ºµÄ¹¤×÷¸üÇáËɸüÓÐЧµÄ»°£¬Ò»¸öºÃµÄ¼à¿Ø¹¤¾ßÊDZز»¿ÉÉÙµÄÁË¡£ÔÚÕâÀïÎÒÏò ......
1. Í£µ½ÔËÐеÄmysql: /etc/init.d/mysql stop
2. ʹÓÃskip-grant-tablesÕâ¸öÑ¡ÏîÆô¶¯MySQL£º /usr/bin/mysqld_safe --skip-grant-tables &
3. ÏÖÔÚ¿ÉÒÔ²»ÓÃÃÜÂë½øÈëmysql ÁË¡£
# myql
>   ......
ÓÐÁ½ÖÖ·½·¨¡£
·½·¨Ò»£ºÔÚmysql>Ìáʾ·ûÖÐʹÓÃtee
mysql> tee output.txt
Logging to file 'output.txt'
mysql> notee
Outfile disabled.
»òÕß
mysql> \T output.txt
Logging to file 'output.txt'
mysql> \t
Outfile disabled.
Õâ¸öÀàËÆÓÚsqlplusµÄspool¹¦ÄÜ£¬¿ÉÒÔ½«ÃüÁîÐÐÖеĽá¹û±£´æµ½Í ......
1. Mysql Åàѵ
1.1. ÅàѵĿµÄ
±¾ÎĵµÊÇÕë¶ÔMySQL Êý¾Ý¿â·½ÃæµÄ»ù´¡Åàѵ£¬ÎªÁËʹÏîÄ¿×é³ÉÔ±Äܹ»´ïµ½Ê¹ÓÃMySQL Êý¾Ý¿âµÄÄ¿µÄ¡£
1.2. Åàѵ¶ÔÏó
¿ª·¢ÈËÔ±
1.3. ³£Óôʼ°·ûºÅ˵Ã÷
³£Óôʣº
Mysql£ºÒ»ÖÖÃâ·ÑµÄ¿çƽ̨µÄÊý¾Ý¿âϵͳ
E:\mysql£º±íʾÊÇÔÚdos ÃüÁî´°¿ÚÏÂÃæ
mysql> ±íʾÊÇÔÚmysql µÄÃüÁîÐÐÏÂ
1.4 ......
±¸·ÝMySQLÊý¾Ý¿âµÄÃüÁî
mysqldump -hhostname -uusername -ppassword databasename > backupfile.sql
±¸·ÝMySQLÊý¾Ý¿âΪ´øɾ³ý±íµÄ¸ñʽ
±¸·ÝMySQLÊý¾Ý¿âΪ´øɾ³ý±íµÄ¸ñʽ£¬Äܹ»Èøñ¸·Ý¸²¸ÇÒÑÓÐÊý¾Ý¿â¶ø²»ÐèÒªÊÖ¶¯É¾³ýÔÓÐÊý¾Ý¿â¡£
mysqldump -–add-drop-table -uusername -ppassword databasename > backu ......