<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: mysql code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 24 Jul 2008 07:55:23 GMT</pubDate>
    <description>DZone Snippets: mysql code</description>
    <item>
      <title>Compare Engines </title>
      <link>http://snippets.dzone.com/posts/show/5806</link>
      <description>// If you have 2 servers with identical database structure, and some of the tables have different engine type, then create a federated table to connect to the original server and compare the engines type with the current table's engine.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;CREATE TABLE test.`TABLES2` (&lt;br /&gt;`TABLE_CATALOG` varchar(512) default NULL,&lt;br /&gt;`TABLE_SCHEMA` varchar(64) NOT NULL default '',&lt;br /&gt;`TABLE_NAME` varchar(64) NOT NULL default '',&lt;br /&gt;`TABLE_TYPE` varchar(64) NOT NULL default '',&lt;br /&gt;`ENGINE` varchar(64) default NULL,&lt;br /&gt;`VERSION` bigint(21) default NULL,&lt;br /&gt;`ROW_FORMAT` varchar(10) default NULL,&lt;br /&gt;`TABLE_ROWS` bigint(21) default NULL,&lt;br /&gt;`AVG_ROW_LENGTH` bigint(21) default NULL,&lt;br /&gt;`DATA_LENGTH` bigint(21) default NULL,&lt;br /&gt;`MAX_DATA_LENGTH` bigint(21) default NULL,&lt;br /&gt;`INDEX_LENGTH` bigint(21) default NULL,&lt;br /&gt;`DATA_FREE` bigint(21) default NULL,&lt;br /&gt;`AUTO_INCREMENT` bigint(21) default NULL,&lt;br /&gt;`CREATE_TIME` datetime default NULL,&lt;br /&gt;`UPDATE_TIME` datetime default NULL,&lt;br /&gt;`CHECK_TIME` datetime default NULL,&lt;br /&gt;`TABLE_COLLATION` varchar(64) default NULL,&lt;br /&gt;`CHECKSUM` bigint(21) default NULL,&lt;br /&gt;`CREATE_OPTIONS` varchar(255) default NULL,&lt;br /&gt;`TABLE_COMMENT` varchar(80) NOT NULL default ''&lt;br /&gt;)&lt;br /&gt;ENGINE=FEDERATED DEFAULT CHARSET=latin1&lt;br /&gt;CONNECTION='mysql://root@172.172.172.172/information_schema/TABLES';&lt;br /&gt;&lt;br /&gt;SELECT b.TABLE_SCHEMA as remote_database, b.TABLE_NAME as remote_tableName, b.ENGINE as remote_engine, a.ENGINE AS local_engine &lt;br /&gt;FROM test.TABLES2 AS a INNER JOIN information_schema.TABLES as b &lt;br /&gt;ON a.TABLE_SCHEMA = b.TABLE_SCHEMA AND a.TABLE_NAME = b.TABLE_NAME AND a.ENGINE != b.ENGINE;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 22 Jul 2008 05:47:46 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5806</guid>
      <author>shantanuo (shantanu oak)</author>
    </item>
    <item>
      <title>Claves Foraneas / Foreign key</title>
      <link>http://snippets.dzone.com/posts/show/5777</link>
      <description>Integridad de datos mediantes claves Foraneas, script que genera las SQL necesarios para garantizar la integridad entre tablas. Poco a poco vamos relacionando parejas de padre e hijo y podemos realizar un arbol de claves foraneas, cuando si borramos un registro del padre, borra y actualiza a los hijos en cascada, si no me explico bien decirme en los comentarios.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;require_once("cabezera/funciones.php");&lt;br /&gt;conectar_mysql();&lt;br /&gt;require_once("cabezera/scripts/constantes.php");&lt;br /&gt;?&gt;&lt;br /&gt;&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;&lt;br /&gt;&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;br /&gt;&lt;head&gt;&lt;br /&gt;&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" /&gt;&lt;br /&gt;&lt;title&gt;Untitled Document&lt;/title&gt;&lt;br /&gt;&lt;/head&gt;&lt;br /&gt;&lt;br /&gt;&lt;body&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;$ejecutar = isset($_GET['ejecutar']) &amp;&amp; $_GET['ejecutar']=='si';&lt;br /&gt;$tabla_padre = "album";&lt;br /&gt;$tabla_hijo = "fotos";&lt;br /&gt;$campo_padre = "idAlbum";&lt;br /&gt;$campo_hijo = "idAlbum";&lt;br /&gt;&lt;br /&gt;$sinIntegridad = 0;&lt;br /&gt;&lt;br /&gt;$sql="select * from ".$tabla_hijo;&lt;br /&gt;$resultado = mysql_query($sql);&lt;br /&gt;while($fila = mysql_fetch_array($resultado))&lt;br /&gt;{&lt;br /&gt;	$sql2 = "select * from ".$tabla_padre." where ".$campo_padre." = '".$fila[$campo_hijo]."'";&lt;br /&gt;	//echo $sql2."&lt;br/&gt;";&lt;br /&gt;	$resultado2 = mysql_query($sql2);&lt;br /&gt;	if(mysql_num_rows($resultado2) &lt;= 0)&lt;br /&gt;	{&lt;br /&gt;		$sql3 = "DELETE FROM `".$tabla_hijo."` WHERE `".$campo_hijo."` = '".$fila[$campo_hijo]."' LIMIT 1;";&lt;br /&gt;		if($ejecutar)&lt;br /&gt;		{&lt;br /&gt;			if(mysql_query($sql3)) echo "OK query : ".$sql3."&lt;br /&gt;";&lt;br /&gt;			else echo "Error en query : ".$sql3."&lt;br /&gt;";&lt;br /&gt;		}&lt;br /&gt;		else&lt;br /&gt;		{&lt;br /&gt;			echo $sql3."&lt;br/&gt;";&lt;br /&gt;		}&lt;br /&gt;		$sinIntegridad++;&lt;br /&gt;	}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;$sql1="ALTER TABLE `".$tabla_padre."` ADD INDEX ( `".$campo_padre."` ) ";&lt;br /&gt;$sql2="ALTER TABLE `".$tabla_hijo."` ADD INDEX ( `".$campo_hijo."` ) ";&lt;br /&gt;$sql3="ALTER TABLE ".$tabla_hijo." ADD FOREIGN KEY(".$campo_hijo.") REFERENCES ".$tabla_padre." (".$campo_padre.") ON DELETE CASCADE ON UPDATE CASCADE";&lt;br /&gt;if($ejecutar)&lt;br /&gt;{&lt;br /&gt;	if(mysql_query($sql1)) echo "OK query : ".$sql1."&lt;br /&gt;";&lt;br /&gt;	else echo "Error en query : ".$sql1."&lt;br /&gt;";&lt;br /&gt;	&lt;br /&gt;	if(mysql_query($sql2)) echo "OK query : ".$sql2."&lt;br /&gt;";&lt;br /&gt;	else echo "Error en query : ".$sql2."&lt;br /&gt;";&lt;br /&gt;	&lt;br /&gt;	if(mysql_query($sql3)) echo "OK query : ".$sql3."&lt;br /&gt;";&lt;br /&gt;	else echo "Error en query : ".$sql3."&lt;br /&gt;";&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;	echo $sql1."&lt;br/&gt;";&lt;br /&gt;	echo $sql2."&lt;br/&gt;";&lt;br /&gt;	echo $sql3."&lt;br/&gt;";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;echo "&lt;br/&gt;".$sinIntegridad." filas sin integridad.&lt;br/&gt;";&lt;br /&gt;?&gt;&lt;br /&gt;&lt;form id="form1" name="form1" method="get" action=""&gt;&lt;br /&gt;  &lt;label&gt;&lt;br /&gt;  &lt;input name="ejecutar" type="hidden" id="ejecutar" value="si" /&gt;&lt;br /&gt;  &lt;input name="Button" type="button" onclick="location.href=location.href" value="Recargar sin ejecutar nada" /&gt;&lt;br /&gt;  &lt;input type="submit" name="button" id="button" value="Ejecutar SQL!" /&gt;&lt;br /&gt;  &lt;/label&gt;&lt;br /&gt;&lt;/form&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;/*&lt;br /&gt;ALTER TABLE fotos_nueva_version ADD FOREIGN KEY(idUsuario) REFERENCES usuarios_portalcocinas (idUsuario) ON DELETE CASCADE ON UPDATE CASCADE&lt;br /&gt;&lt;br /&gt;ALTER TABLE relacion_usuario_localidad ADD FOREIGN KEY(idUsuario) REFERENCES usuarios_portalcocinas (idUsuario) ON DELETE CASCADE ON UPDATE CASCADE&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ALTER TABLE relacion_usuario_actividad ADD FOREIGN KEY(idUsuario) REFERENCES usuarios_portalcocinas (idUsuario) ON DELETE CASCADE ON UPDATE CASCADE&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ALTER TABLE fotos_nueva_version DROP FOREIGN KEY idUsuario_FK;&lt;br /&gt;&lt;br /&gt;SHOW CREATE TABLE fotos_nueva_version;&lt;br /&gt;*/&lt;br /&gt;?&gt;&lt;br /&gt;&lt;/body&gt;&lt;br /&gt;&lt;/html&gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 16 Jul 2008 12:18:14 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5777</guid>
      <author>Ricardo (Ricardo m. Garc&#237;a)</author>
    </item>
    <item>
      <title>Query MySQL accent insensitive in latin1_general_ci</title>
      <link>http://snippets.dzone.com/posts/show/5677</link>
      <description>Query MySQL accent insensitive in latin1_general_ci&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;SELECT * FROM `table`WHERE `text` LIKE CONVERT(_utf8 '%cinema%' USING utf8) COLLATE utf8_general_ci ;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.ab-d.fr/"&gt;Source: &lt;/a&gt;&lt;a href="http://www.ab-d.fr/date/2008-06-21/"&gt;Query MySQL accent insensitive in latin1_general_ci&lt;/a&gt;</description>
      <pubDate>Sat, 21 Jun 2008 10:34:59 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5677</guid>
      <author>ki4ngel (Benoit Asselin)</author>
    </item>
    <item>
      <title>export and import by php</title>
      <link>http://snippets.dzone.com/posts/show/5654</link>
      <description>There are at least three ways to backup your MySQL Database :&lt;br /&gt;&lt;br /&gt;Execute a database backup query from PHP file.&lt;br /&gt;Run mysqldump using system() function.&lt;br /&gt;Use phpMyAdmin to do the backup.&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Execute a database backup query from PHP file&lt;br /&gt;&lt;br /&gt;Below is an example of using SELECT INTO OUTFILE query for creating table backup :&lt;br /&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;include 'config.php';&lt;br /&gt;include 'opendb.php';&lt;br /&gt;&lt;br /&gt;$tableName  = 'mypet';&lt;br /&gt;$backupFile = 'backup/mypet.sql';&lt;br /&gt;$query      = "SELECT * INTO OUTFILE '$backupFile' FROM $tableName";&lt;br /&gt;$result = mysql_query($query);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;include 'closedb.php';&lt;br /&gt;?&gt;&lt;br /&gt;To restore the backup you just need to run LOAD DATA INFILE query like this :&lt;br /&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;include 'config.php';&lt;br /&gt;include 'opendb.php';&lt;br /&gt;&lt;br /&gt;$tableName  = 'mypet';&lt;br /&gt;$backupFile = 'mypet.sql';&lt;br /&gt;$query      = "LOAD DATA INFILE 'backupFile' INTO TABLE $tableName";&lt;br /&gt;$result = mysql_query($query);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;include 'closedb.php';&lt;br /&gt;?&gt;&lt;br /&gt;It's a good idea to name the backup file as tablename.sql so you'll know from which table the backup file is&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Run mysqldump using system() function</description>
      <pubDate>Mon, 16 Jun 2008 07:34:06 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5654</guid>
      <author>ajay1kumar1 (Ajay kumar)</author>
    </item>
    <item>
      <title>Processing large CSV files</title>
      <link>http://snippets.dzone.com/posts/show/5627</link>
      <description>&lt;code&gt;&lt;br /&gt;  # this method allows fast CSV processing, it reads file_name, generates a new&lt;br /&gt;  # CSV file and inserts all data in a mysql table using LOAD DATA INFILE&lt;br /&gt;&lt;br /&gt;    # you can use it like this:&lt;br /&gt;&lt;br /&gt;    load_csv_data(PRELOAD_DIR+'socios.csv', 'users') do |csv, thing_id, row|&lt;br /&gt;      csv &lt;&lt; [thing_id,&lt;br /&gt;        row['NOMBRE'].to_s.to_permalink+'.'+row['APELLIDOS'].to_s.to_permalink, #  login&lt;br /&gt;        row['E_MAIL'], #  email&lt;br /&gt;        row['SEXO'],  #  gender&lt;br /&gt;        (row['NO_DATOS'] == 'S' || row['NO_DATOS'] == 'VERDADERO' ? 1 : 0 ), #  no_datos&lt;br /&gt;      ]&lt;br /&gt;    end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  def load_csv_data(file_name, table_name)&lt;br /&gt;    STDERR.print("\nParsing '#{file_name}' to insert data in '#{table_name}'\n")&lt;br /&gt;&lt;br /&gt;    n_lines = (%x[wc -l #{file_name}]).split(' ')[0].to_f&lt;br /&gt;    time_start = Time.now&lt;br /&gt;    begin&lt;br /&gt;      require 'fastercsv'&lt;br /&gt;      count = 0.0&lt;br /&gt;&lt;br /&gt;      csv_string = FasterCSV.open("data.csv", "w", { :col_sep =&gt; ";", :force_quotes =&gt; true })  do |csv|&lt;br /&gt;      FasterCSV.open("#{file_name}", { :col_sep =&gt; "\t", :headers =&gt; :first_row }).each do |row|&lt;br /&gt;        thing_id = row[0].to_i&lt;br /&gt;        if thing_id &amp;&amp; thing_id &gt; 0&lt;br /&gt;          &lt;br /&gt;          yield csv, thing_id, row&lt;br /&gt;&lt;br /&gt;          percentage = ((count += 1) * 100.0)/n_lines&lt;br /&gt;          STDERR.print "%.0f%%..." % percentage if (percentage.modulo(2.0) &lt; 0.001)&lt;br /&gt;        end&lt;br /&gt;        end&lt;br /&gt;      end&lt;br /&gt;    rescue EOFError&lt;br /&gt;      f.close&lt;br /&gt;    end&lt;br /&gt;    total_lines = (%x[wc -l data.csv]).split(' ')[0].to_i&lt;br /&gt;    STDERR.print("\nInserting #{total_lines} lines in table '#{table_name}'\n")&lt;br /&gt;    ActiveRecord::Base.connection.execute("LOAD DATA INFILE '#{File.join(File.dirname(__FILE__), '..', '..', 'data.csv')}' IGNORE INTO TABLE #{table_name} FIELDS TERMINATED BY ';' ENCLOSED BY '\"';")&lt;br /&gt;    warn("Finished importing '#{file_name}'.\nLines: #{n_lines.to_i.to_s} (#{(n_lines.to_i - total_lines.to_i).to_s} lost)\nTime: %.2f minutes\n" % ((Time.now - time_start)/60))&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 10 Jun 2008 11:17:48 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5627</guid>
      <author>demimismo (David Arango)</author>
    </item>
    <item>
      <title>Getting ActiveRecord to auto reconnect after lost connection</title>
      <link>http://snippets.dzone.com/posts/show/5519</link>
      <description>I puts this code in a file called active_record_hacks.rb in config/initializers but it could easily be a plugin.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;ActiveRecord::ConnectionAdapters::MysqlAdapter.module_eval do&lt;br /&gt;  def execute_with_retry_once(sql, name = nil)&lt;br /&gt;    retried = false&lt;br /&gt;    begin&lt;br /&gt;      execute_without_retry_once(sql, name)&lt;br /&gt;    rescue ActiveRecord::StatementInvalid =&gt; exception&lt;br /&gt;      ActiveRecord::Base.logger.info "#{exception}, retried? #{retried}"&lt;br /&gt;&lt;br /&gt;      # Our database connection has gone away, reconnect and retry this method&lt;br /&gt;      reconnect!&lt;br /&gt;      unless retried&lt;br /&gt;        retried = true&lt;br /&gt;        retry&lt;br /&gt;      end&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  alias_method_chain :execute, :retry_once&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 19 May 2008 15:47:42 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5519</guid>
      <author>bmarini (Ben Marini)</author>
    </item>
    <item>
      <title>Copy MySQL table</title>
      <link>http://snippets.dzone.com/posts/show/5489</link>
      <description>&lt;code&gt;&lt;br /&gt;CREATE TABLE table_destination SELECT * FROM table_source ;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;CREATE TABLE table_destination LIKE table_source ;&lt;br /&gt;INSERT INTO table_destination SELECT * FROM table_source ;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Source: &lt;a href="http://www.ab-d.fr/"&gt;Asselin Benoit Development ( MySQL, SQL )&lt;/a&gt; &amp; &lt;a href="http://www.agenceici.com"&gt;Agence ici, agence de communication&lt;/a&gt;</description>
      <pubDate>Tue, 13 May 2008 17:31:35 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5489</guid>
      <author>ki4ngel (Benoit Asselin)</author>
    </item>
    <item>
      <title>PHP Dynamic Checkbox Table Creator (data retrieved from MySQL DB)</title>
      <link>http://snippets.dzone.com/posts/show/5450</link>
      <description>Hi All.&lt;br /&gt;This is a function for Dynamically Create a Checbox Table retrieving information for from a MySQL Database.&lt;br /&gt;As it is quite commented, it's also good for learning how this things work :)&lt;br /&gt;Hope you find it useful.&lt;br /&gt;Feedback is welcome.&lt;br /&gt;Cheers&lt;br /&gt;Dan&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;function dynamic_checkbox_table ($sql_str, $col_label, $col_name, $val_checked="S", $cant_cols_tbl=3){&lt;br /&gt;/*&lt;br /&gt;	by Daniel Neumann&lt;br /&gt;	this script creates dynamically permite a table containing checkboxes &lt;br /&gt;	getting the data for the checkboxes from a MySQL DB&lt;br /&gt;	$sql_str, SQL select string to retrieve data from DB (see example in last comment line)&lt;br /&gt;	$col_label, DB column that has values for the checkbox label &lt;br /&gt;	$col_name, DB column that has values for the checkbox name&lt;br /&gt;	$val_checked="S", value when checked (value="" attribute) it uses the same value for all of them. If you whish to use a dynamic value from a DB, you should comment the line (it&#180;s explained next to the code in the middle of the function) and de-comment the other line (check the code,. you'll understand what I mean). Also, you should use this parameter to specify the column name for the values&lt;br /&gt;	$cant_cols_tbl=3, quantity of columns for the table, it defaults to 3&lt;br /&gt;	usage example: dynamic_checkbox_table("SELECT * FROM keywords", "Keyword", "ID_Keywrd");&lt;br /&gt;*/&lt;br /&gt;	&lt;br /&gt;	//connect DB and run query&lt;br /&gt;	$db="MyDB";&lt;br /&gt;	$db_user="MyUser";&lt;br /&gt;	$pass="MyPass";&lt;br /&gt;	$host="localhost";&lt;br /&gt;	@mysql_connect($host,$db_user,$pass);&lt;br /&gt;	@mysql_select_db($db) or die ("cannot connect to DB");&lt;br /&gt;	$q_resultado = mysql_query($sql_str);&lt;br /&gt;	mysql_close();&lt;br /&gt;	if (mysql_num_rows($q_resultado)==0) exit("no rows returned");&lt;br /&gt;	&lt;br /&gt;	$next_row = mysql_fetch_array($q_resultado); //fetch first row&lt;br /&gt;	&lt;br /&gt;	$output = "&lt;table  border=\"1\"&gt;\n"; //open table tag&lt;br /&gt;	do {&lt;br /&gt;		$output .= "&lt;tr&gt;\n"; //open row tag&lt;br /&gt;		for ($i=1 ; $i &lt;= $cant_cols_tbl ; $i++ ){ //loops as many times as $cant_cols_tbl&lt;br /&gt;			$row=$next_row; //assign $row, next row will be checking next one, that avoids starting a new row when it's gonna be empty&lt;br /&gt;			$output .= "&lt;td&gt;"; //open TD tag&lt;br /&gt;			$output .= (!$row) ? "" : '&lt;input type="checkbox" name="'.$row[$col_name].'" value="'.$val_checked.'" /&gt;'.$row[$col_label]; //create checkbox and data from $row (**** you should comment this line if you whish to use dynamic $val_checked****)&lt;br /&gt;//			echo (!$row) ? "" : '&lt;input type="checkbox" name="'.$row[$col_name].'" value="'.$row[$val_checked].'" /&gt;'.$row[$col_label]; //create checkbox and data from $row (**** you should de-comment this line if you whish to use dynamic $val_checked****)&lt;br /&gt;			$next_row = mysql_fetch_array($q_resultado); //retrieve next row&lt;br /&gt;			$output .= "&lt;/td&gt;\n"; //close TD&lt;br /&gt;		} //close for loop&lt;br /&gt;		$output .= "&lt;/tr&gt;\n"; //close row&lt;br /&gt;	} while ($next_row); //close do-while (and checks if there's another row)&lt;br /&gt;	$output .= "&lt;/table&gt;\n"; //close table&lt;br /&gt;	return $output; &lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 02 May 2008 12:09:34 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5450</guid>
      <author>dneuma (Daniel Neumann)</author>
    </item>
    <item>
      <title>Transfer Wordpress MySQL database to new webhost</title>
      <link>http://snippets.dzone.com/posts/show/5361</link>
      <description>// Transfer Wordpress MySQL database to new webhost in 3 steps (assumes: A. files have already been copied over, B. database created on new server, C. database user created on new server, D. wp-config.php updated on new server)&lt;br /&gt;// 1. login to old host via ssh, run this command:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;mysqldump -h DB_HOST -u DB_USER -p DB_NAME &gt; dump.sql&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;// replace DB_HOST, DB_USER, &amp; DB_NAME with info from the local wp-config.php file&lt;br /&gt;// when asked for password, enter DB_PASSWORD from the local wp-config.php file&lt;br /&gt;&lt;br /&gt;// 2. copy dump.sql to your new host using sftp&lt;br /&gt;&lt;br /&gt;// 3. login go new host via ssh, run this command:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;mysql -h DB_HOST -u DB_USER -p DB_NAME &lt; dump.sql&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;// replace DB_HOST, DB_USER, &amp; DB_NAME with info from the local wp-config.php file&lt;br /&gt;// when asked for password, enter DB_PASSWORD from the local wp-config.php file&lt;br /&gt;&lt;br /&gt;// adopted from this page: http://technosailor.com/2007/04/06/wordpress-faq-how-do-i-move-my-blog-to-a-new-host/</description>
      <pubDate>Mon, 14 Apr 2008 07:54:58 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5361</guid>
      <author>SimonDorfman (Simon Dorfman)</author>
    </item>
    <item>
      <title>how to create a new user in MySQL</title>
      <link>http://snippets.dzone.com/posts/show/5277</link>
      <description>// first, mysql -uroot mysql&lt;br /&gt;// then:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;br /&gt;  mysql% GRANT ALL PRIVILEGES ON *.* TO 'jm3_spoon'@'localhost' IDENTIFIED BY 'stirthatshit' WITH GRANT OPTION;&lt;br /&gt;  mysql% create database jm3_agitator;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 24 Mar 2008 04:06:23 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5277</guid>
      <author>jm3 (john manoogian III)</author>
    </item>
  </channel>
</rss>
