<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>石无言 &#187; MySQL</title>
	<atom:link href="http://www.hugstone.com/index.php/archives/tag/mysql/feed" rel="self" type="application/rss+xml" />
	<link>http://www.hugstone.com</link>
	<description>三生石前问一声，人间哪里修正果！</description>
	<lastBuildDate>Wed, 28 Jul 2010 02:11:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>[MySQL] 相关SQL语句</title>
		<link>http://www.hugstone.com/index.php/archives/444</link>
		<comments>http://www.hugstone.com/index.php/archives/444#comments</comments>
		<pubDate>Thu, 14 Jan 2010 10:11:46 +0000</pubDate>
		<dc:creator>stone</dc:creator>
				<category><![CDATA[Note]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.hugstone.com/?p=444</guid>
		<description><![CDATA[连接数据库：mysql [host] –u [user] –p
查看数据库：show databases;  列出数据库服务器上所有数据库
查看当前使用的数据库：select database(); 
使用数据库：use [database name]  ; 切换到需要操作的数据库
查看表：    [......]<p class='read-more'><a href='http://www.hugstone.com/index.php/archives/444'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<p>连接数据库：mysql [host] –u [user] –p<br />
查看数据库：show databases;  列出数据库服务器上所有数据库<br />
查看当前使用的数据库：select database(); <br />
使用数据库：use [database name]  ; 切换到需要操作的数据库<br />
查看表：      show tables;  列出当前所在数据库的所有表<br />
查看表结构：describe [table name] ;  查看表结构</p>
<p>数据库的授权：grant all privileges on *.* to 'root'@'localhost' identified by 'zg'<br />
这句话的意思是让用户root可以从localhost登陆，并对所有的数据库有权限,密码是zg<br />
它相当于在数据库mysql的user表中添加了一条记录,此表以user与host为主键<br />
如想更新密码可以这样:update user set password=password(密码) where user=? and password=?</p>
<p>导入.sql文件(该文件包含表及相关数据):<br />
[root@mylocal001 ~]# mysql -u root -p posdb &lt; /soft/war/posdb.sql</p>
<p>LIMIT子句<br />
MS SQLSERVER 中有SELECT TOP语句, Oracle中有ROWNUM序列,那么MYSQL中如何实现select top n效果?<br />
使用Mysql中的LIMIT子句<br />
用法:　select * from Table limit n,m;<br />
limit n,m的含义是从n开始取,取m条记录</p>
<p>*当使用update语句时,LIMIT子句用于给定一个限值，限制可以被更新的行的数目。<br />
update Table set col_name1=expr1 [, col_name2=expr2 ...] limit 1000;</p>
<p>查看系统中支持的存储引擎类型：show engines;<br />
查看某个存储引擎的具体信息： show engine InnoDB status;<br />
创建表时指定存储引擎的类型： CREATE TABLE tablename (id int, title char(20)) ENGINE = INNODB;<br />
修改现有的表使用的存储引擎：  ALTER TABLE tablename ENGINE = MyISAM;<br />
查看某个库中所有表的存储引擎：show table status from DBName;<br />
查看某个库中单个表的存储引擎：show create table DBName.TableName;</p>
<p>查看Mysql版本(三种方法):<br />
mysql&gt;status;<br />
mysql&gt;select version();<br />
[root@mylocal001 ~] # mysql -V</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hugstone.com/index.php/archives/444/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[MySQL] Apply secrurity Settings 失败 问题记录</title>
		<link>http://www.hugstone.com/index.php/archives/289</link>
		<comments>http://www.hugstone.com/index.php/archives/289#comments</comments>
		<pubDate>Mon, 04 May 2009 03:27:47 +0000</pubDate>
		<dc:creator>stone</dc:creator>
				<category><![CDATA[Note]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.hugstone.com/?p=289</guid>
		<description><![CDATA[机器环境: Redhat RHEL 5 中vmware下的XP虚拟系统 .
安装Mysql5.1.33在MySQL Server Instance Config Wizard时，Apply secrurity Settings 失败，错误信息为不能连接到该端口，请查看是否关闭防火墙，能及相关端口是否[......]<p class='read-more'><a href='http://www.hugstone.com/index.php/archives/289'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<p>机器环境: Redhat RHEL 5 中vmware下的XP虚拟系统 .</p>
<p>安装Mysql5.1.33在MySQL Server Instance Config Wizard时，Apply secrurity Settings 失败，错误信息为不能连接到该端口，请查看是否关闭防火墙，能及相关端口是否可用之类的提示；查看Linux系统的防火墙规则，没有任何限制，而XP自身的防火墙也关闭了，相关端口也没被占用，试了几次（完全卸载重新安装）都不能通过Apply secrurity Settings 这一步。</p>
<p>最后无意中在set network options 中将Add firewall exception for this port 选项选中，再次<span style="font-size: 10.5pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA;" lang="EN-US">Execute，配置成功！</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hugstone.com/index.php/archives/289/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[MySQL] MySQL区分大小写问题</title>
		<link>http://www.hugstone.com/index.php/archives/239</link>
		<comments>http://www.hugstone.com/index.php/archives/239#comments</comments>
		<pubDate>Wed, 22 Apr 2009 05:16:38 +0000</pubDate>
		<dc:creator>stone</dc:creator>
				<category><![CDATA[Note]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.hugstone.com/?p=239</guid>
		<description><![CDATA[这次一个数据采集的项目在开发的时候在WINDOWS平台下开发的，开发完了之后在LINUX环境上部署好之后，运行时MySQL数据库报错，提示为某个表不存在之类的错误信息，后来修改了MySQL的配置文件将大小写敏感去掉，问题解决。
这个问题的根源在于，在 MySQL 中，数据库和表其实就是数据目录下的目[......]<p class='read-more'><a href='http://www.hugstone.com/index.php/archives/239'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<p>这次一个数据采集的项目在开发的时候在WINDOWS平台下开发的，开发完了之后在LINUX环境上部署好之后，运行时MySQL数据库报错，提示为某个表不存在之类的错误信息，后来修改了MySQL的配置文件将大小写敏感去掉，问题解决。</p>
<p>这个问题的根源在于，在 MySQL 中，数据库和表其实就是数据目录下的目录和文件，因而，操作系统的敏感性决定数据库和表命名的大小写敏感。这就意味着数据库和表名在 Windows 中是大小写不敏感的，而在大多数类型的 Unix/Linux 系统中是大小写敏感的。</p>
<p>MySQL大小写敏感可以通过配置文件的lower_case_table_names参数来控制。</p>
<p>WINDOWS：<br />
编辑MySQL安装目录下的my.ini 文件，在[mysqld]节下 添加 lower_case_table_names=0 (备注：为0时大小写敏感，为1时大小写不敏感，默认为1)，可以实现MySql按照建表Sql语句的大小写状态来定义表名。</p>
<p>LINUX：<br />
编辑/etc/my.cnf文件,在[mysqld]节下 添加 lower_case_table_names 参数，并设置相应的值 (备注：为0时大小写敏感，为1时大小写不敏感，默认为0)。</p>
<p>关于 数据目录</p>
<p>数据目录是用来存放数据表和相关信息的地方，是数据库的核心。在MySQL中的数据目录根据不同平台的有一些差异：</p>
<p>在Unix/Linux系统上，如果用源码编译安装，数据目录的位置默认是在/usr/local/mysql/var中；</p>
<p>在UNIX/Linux系统上，如果用二进制发行版安装，数据目录的位置默认是在/usr/local/mysql/data中；</p>
<p>在Windows系统上，数据目录的位置默认是在C:\Documents and Settings\All Users\Application Data\MySQL\MySQL Server 5.1\data中；</p>
<p>PS: Identifier Case Sensitivity</p>
<p>How table and database names are stored on disk and used in MySQL is affected by the <span style="color: #3366ff;"><code class="literal">lower_case_table_names</code> </span>system variable, which you can set when starting <strong class="command"><span style="color: #ff0000;">mysqld</span></strong>. <code class="literal"><span style="color: #3366ff;">lower_case_table_names</span></code> can take the values shown in the following table. This variable does <span class="emphasis"><em>not</em></span> affect case sensitivity of trigger identifiers. On Unix, the default value of <code class="literal"><span style="color: #3366ff;">lower_case_table_names</span></code> is 0. On Windows the default value is 1. On Mac OS X, the default value is 2.</p>
<div class="informaltable">
<table border="1">
<colgroup span="2">
<col span="2"></col>
<col span="2"></col>
</colgroup>
<tbody>
<tr>
<td><span class="bold"><strong>Value</strong></span></td>
<td><span class="bold"><strong>Meaning</strong></span></td>
</tr>
<tr>
<td><code class="literal">0</code></td>
<td>Table and database names are stored on disk using the lettercase specified in the <span style="color: #0000ff;"><code class="literal">CREATE TABLE</code> </span>or <code class="literal"><span style="color: #0000ff;">CREATE DATABASE</span></code> statement. Name comparisons are case sensitive. Note that if you force this variable to 0 with <code class="option">--lower-case-table-names=0</code> on a case-insensitive filesystem and access <code class="literal">MyISAM</code> tablenames using different lettercases, index corruption may result.</td>
</tr>
<tr>
<td><code class="literal">1</code></td>
<td>Table names are stored in lowercase on disk and name comparisons are not case sensitive. MySQL converts all table names to lowercase on storage and lookup. This behavior also applies to database names and table aliases.</td>
</tr>
<tr>
<td><code class="literal">2</code></td>
<td>Table and database names are stored on disk using the lettercase specified in the <code class="literal"><span style="color: #0000ff;">CREATE TABLE</span></code> or <code class="literal"><span style="color: #0000ff;">CREATE DATABASE</span></code> statement, but MySQL converts them to lowercase on lookup. Name comparisons are not case sensitive. This works <span class="emphasis"><em>only</em></span> on filesystems that are not case sensitive! <code class="literal">InnoDB</code> table names are stored in lowercase, as for <code class="literal">lower_case_table_names=1</code>.</td>
</tr>
</tbody>
</table>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.hugstone.com/index.php/archives/239/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[MySQL] Could not start the service MySQL 解决方法</title>
		<link>http://www.hugstone.com/index.php/archives/217</link>
		<comments>http://www.hugstone.com/index.php/archives/217#comments</comments>
		<pubDate>Wed, 15 Apr 2009 06:20:10 +0000</pubDate>
		<dc:creator>stone</dc:creator>
				<category><![CDATA[Note]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.hugstone.com/?p=217</guid>
		<description><![CDATA[安装mysql 5.1.33,在运行Server Instance Configuration wizard时的Execute configurattion步骤中的第三项Start Service进出错,错误提示为Could not start the service MySQL (出现这种情况一般[......]<p class='read-more'><a href='http://www.hugstone.com/index.php/archives/217'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<p>安装mysql 5.1.33,在运行Server Instance Configuration wizard时的Execute configurattion步骤中的第三项Start Service进出错,错误提示为Could not start the service MySQL (出现这种情况一般是因为装过mysql，卸载不干净造成的。卸载后重启后再重装。注意看下服务，如果未能卸载，可以用mysqld-nt -remove卸载)。</p>
<p>具体方法如下:<br />
查看服务中有没有mysql,如果有将该服务停掉;<br />
在控制面板中运行添加删除程序，将mysql卸载;<br />
卸载后打开注册表，查看HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services 下的键值，如果有相关mysql键值(mysql、mysqladmin)则删掉，即可;<br />
重启，将mysql的安装残余目录删掉 (查看服务，此时服务中已没有mysql);<br />
重新安装mysql.安装后先不要运行Server Instance Configuration wizard，重启后在开始菜单中运行该向导，即可。</p>
<p>PS:一种值得参考的方法<br />
(<br />
Remember, windows machines love being rebooted.<br />
For less headaches, do the following:</p>
<p>Uninstall mysql. Reboot the computer. Reinstall mysql, but don't configure yet! Reboot the computer again. Then run Mysql Instance Config Wizard (found in START menu).</p>
<p>Good Luck! <img src='http://www.hugstone.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hugstone.com/index.php/archives/217/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
