﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-★Snowhill ★-文章分类-数据库-mysql</title><link>http://www.cppblog.com/snowhill/category/20653.html</link><description>&lt;font color=#5555aa &gt;&lt;b&gt; 颠沛必于是，造次必于是！&lt;/b&gt;&lt;/font&gt;</description><language>zh-cn</language><lastBuildDate>Wed, 07 Oct 2015 13:00:55 GMT</lastBuildDate><pubDate>Wed, 07 Oct 2015 13:00:55 GMT</pubDate><ttl>60</ttl><item><title>mysql－－备份篇</title><link>http://www.cppblog.com/snowhill/articles/211957.html</link><dc:creator>snowhill</dc:creator><author>snowhill</author><pubDate>Tue, 06 Oct 2015 16:12:00 GMT</pubDate><guid>http://www.cppblog.com/snowhill/articles/211957.html</guid><wfw:comment>http://www.cppblog.com/snowhill/comments/211957.html</wfw:comment><comments>http://www.cppblog.com/snowhill/articles/211957.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/snowhill/comments/commentRss/211957.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/snowhill/services/trackbacks/211957.html</trackback:ping><description><![CDATA[一启用增量备份<br />　1.1启用binlog<br />&nbsp; &nbsp; binlog_format=mixed<div>&nbsp;&nbsp;&nbsp;log_bin=/data/log/bin_log.log</div><div>&nbsp;&nbsp;&nbsp;expire_logs_days=7</div><div>&nbsp;&nbsp;&nbsp;max_binlog_size =500M</div><div>&nbsp;&nbsp;&nbsp;binlog-do-db=db<br />　2 重启mysql服务<br />&nbsp; 查看binlog<br /><div>mysql&gt; show binary logs;</div><div>mysql&gt; show master status ;<br /><div>mysql&gt; show binlog events in 'bin_log.000003';</div></div>&nbsp; 3 &nbsp;编写存储过程<br /><div><span style="color: #3366ff;">drop procedure if exists pro_test;</span></div><div><span style="color: #3366ff;">CREATE DEFINER=`snowhill`@`%` PROCEDURE `pro_test`()</span></div><div><span style="color: #3366ff;">begin</span></div><div><span style="color: #3366ff;">&nbsp; declare i int;</span></div><div><span style="color: #3366ff;">&nbsp; set i=0;</span></div><div><span style="color: #3366ff;">&nbsp; while i&lt;100 do</span></div><div><span style="color: #3366ff;">&nbsp; &nbsp; &nbsp; insert into T(id,name) values(i,'value');</span></div><div><span style="color: #3366ff;">&nbsp; &nbsp; &nbsp; set i=i+1;</span></div><div><span style="color: #3366ff;">&nbsp; end while;</span></div><div><span style="color: #3366ff;">&nbsp; end;</span></div><div><span style="color: #3366ff;">call pro_test();</span></div><div><span style="color: #3366ff;">select * from T;<br />4性能测试mysqlslap<br />测试500并发<br /><br /></span><span style="color: #002200; font-family: georgia; font-size: 15px; line-height: 22.5px;">mysqlslap -a -c 500 -i 10 -uroot -p123456&nbsp;<br />测试基本写入：<br /></span><div>mysqlslap --auto-generate-sql -u root -p123456<br />其原理就是建一个两个字段的表，然后insert 数据测试．<br />&nbsp;use `mysqlslap`; CREATE TABLE `t1` (intcol1 INT(32) ,charcol1 VARCHAR(128)) &nbsp;</div><span style="color: #002200; font-family: georgia; font-size: 15px; line-height: 22.5px;"><br /><br /></span></div><br /></div><img src ="http://www.cppblog.com/snowhill/aggbug/211957.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/snowhill/" target="_blank">snowhill</a> 2015-10-07 00:12 <a href="http://www.cppblog.com/snowhill/articles/211957.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>mysql--基本管理篇</title><link>http://www.cppblog.com/snowhill/articles/211954.html</link><dc:creator>snowhill</dc:creator><author>snowhill</author><pubDate>Tue, 06 Oct 2015 04:44:00 GMT</pubDate><guid>http://www.cppblog.com/snowhill/articles/211954.html</guid><wfw:comment>http://www.cppblog.com/snowhill/comments/211954.html</wfw:comment><comments>http://www.cppblog.com/snowhill/articles/211954.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/snowhill/comments/commentRss/211954.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/snowhill/services/trackbacks/211954.html</trackback:ping><description><![CDATA[一　引擎管理<br /><span style="color: #454545; font-family: arial, 宋体, sans-serif, tahoma, 'Microsoft YaHei'; line-height: 24px; background-color: #ffffff;">看你的mysql现在已提供什么存储引擎:</span><br style="color: #454545; font-family: arial, 宋体, sans-serif, tahoma, 'Microsoft YaHei'; line-height: 24px; background-color: #ffffff;" /><span style="color: #454545; font-family: arial, 宋体, sans-serif, tahoma, 'Microsoft YaHei'; line-height: 24px; background-color: #ffffff;">mysql&gt; show engines;<br /></span><span style="color: #454545; font-family: arial, 宋体, sans-serif, tahoma, 'Microsoft YaHei'; line-height: 24px; background-color: #ffffff;">看你的mysql当前默认的存储引擎:</span><br style="color: #454545; font-family: arial, 宋体, sans-serif, tahoma, 'Microsoft YaHei'; line-height: 24px; background-color: #ffffff;" /><span style="color: #454545; font-family: arial, 宋体, sans-serif, tahoma, 'Microsoft YaHei'; line-height: 24px; background-color: #ffffff;">mysql&gt; show variables like '%storage_engine%';<br />查看表的存储引擎：<br /></span><span style="color: #454545; font-family: arial, 宋体, sans-serif, tahoma, 'Microsoft YaHei'; line-height: 24px; background-color: #ffffff;">mysql&gt; show create table mysql.user;<br /></span><br />二　用户管理<br />建立用户：<br /><span style="color: #333333; font-family: Verdana, Arial, sans-serif, 'Lucida Grande'; font-size: 13.3333330154419px; line-height: 24px; background-color: #ffffff;">CREATE USER 'user3' @'%' IDENTIFIED BY '123333';<br /></span><span style="background-color: #ffffff;">grant授权也可以建立用户：</span><br /><strong style="color: #333333; font-family: Verdana, Arial, sans-serif, 'Lucida Grande'; font-size: 13.3333330154419px; line-height: 24px; background-color: #ffffff;">grant&nbsp;</strong><strong style="color: #333333; font-family: Verdana, Arial, sans-serif, 'Lucida Grande'; font-size: 13.3333330154419px; line-height: 24px; background-color: #ffffff;">权限</strong><strong style="color: #333333; font-family: Verdana, Arial, sans-serif, 'Lucida Grande'; font-size: 13.3333330154419px; line-height: 24px; background-color: #ffffff;">&nbsp;on&nbsp;</strong><strong style="color: #333333; font-family: Verdana, Arial, sans-serif, 'Lucida Grande'; font-size: 13.3333330154419px; line-height: 24px; background-color: #ffffff;">数据库</strong><strong style="color: #333333; font-family: Verdana, Arial, sans-serif, 'Lucida Grande'; font-size: 13.3333330154419px; line-height: 24px; background-color: #ffffff;">.</strong><strong style="color: #333333; font-family: Verdana, Arial, sans-serif, 'Lucida Grande'; font-size: 13.3333330154419px; line-height: 24px; background-color: #ffffff;">表</strong><strong style="color: #333333; font-family: Verdana, Arial, sans-serif, 'Lucida Grande'; font-size: 13.3333330154419px; line-height: 24px; background-color: #ffffff;">&nbsp;to '</strong><strong style="color: #333333; font-family: Verdana, Arial, sans-serif, 'Lucida Grande'; font-size: 13.3333330154419px; line-height: 24px; background-color: #ffffff;">用户名</strong><strong style="color: #333333; font-family: Verdana, Arial, sans-serif, 'Lucida Grande'; font-size: 13.3333330154419px; line-height: 24px; background-color: #ffffff;">'@'</strong><strong style="color: #333333; font-family: Verdana, Arial, sans-serif, 'Lucida Grande'; font-size: 13.3333330154419px; line-height: 24px; background-color: #ffffff;">登录主机</strong><strong style="color: #333333; font-family: Verdana, Arial, sans-serif, 'Lucida Grande'; font-size: 13.3333330154419px; line-height: 24px; background-color: #ffffff;">' &nbsp;[INDENTIFIED BY &#8216;</strong><strong style="color: #333333; font-family: Verdana, Arial, sans-serif, 'Lucida Grande'; font-size: 13.3333330154419px; line-height: 24px; background-color: #ffffff;">用户密码</strong><strong style="color: #333333; font-family: Verdana, Arial, sans-serif, 'Lucida Grande'; font-size: 13.3333330154419px; line-height: 24px; background-color: #ffffff;">&#8217;];<br />grant all on *.* to 'root'@'localhost' identified by 123456<br />授列级权限：</strong><strong style="color: #333333; font-family: Verdana, Arial, sans-serif, 'Lucida Grande'; font-size: 13.3333330154419px; line-height: 24px; background-color: #d6d3d6;"><br /></strong><div>grant select(user,host,password) on mysql.user to snowhill;<br /><div>mysql&gt; select * from mysq.user;</div><div>ERROR 1142 (42000): SELECT command denied to user 'snowhill'@'localhost' for table 'user'</div><div>mysql&gt; select user,host,password from mysql.user;</div><div>+----------+-----------+-------------------------------------------+</div><div>| user &nbsp; &nbsp; | host &nbsp; &nbsp; &nbsp;| password &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|</div><div>+----------+-----------+-------------------------------------------+</div><div>其中用户密码用的MD5加密，可以用password()函数生成你想要的密码；<br />修改密码：<br /><strong style="color: #333333; font-family: Verdana, Arial, sans-serif, 'Lucida Grande'; font-size: 13.3333330154419px; line-height: 24px; background-color: #d6d3d6;">SET PASSWORD=PASSWORD(&#8216;</strong><strong style="color: #333333; font-family: Verdana, Arial, sans-serif, 'Lucida Grande'; font-size: 13.3333330154419px; line-height: 24px; background-color: #d6d3d6;">新密码</strong><strong style="color: #333333; font-family: Verdana, Arial, sans-serif, 'Lucida Grande'; font-size: 13.3333330154419px; line-height: 24px; background-color: #d6d3d6;">&#8217;);<br /></strong><strong style="color: #333333; font-family: Verdana, Arial, sans-serif, 'Lucida Grande'; font-size: 13.3333330154419px; line-height: 24px; background-color: #d6d3d6;">SET PASSWORD FOR &#8216;</strong><strong style="color: #333333; font-family: Verdana, Arial, sans-serif, 'Lucida Grande'; font-size: 13.3333330154419px; line-height: 24px; background-color: #d6d3d6;">用户名称</strong><strong style="color: #333333; font-family: Verdana, Arial, sans-serif, 'Lucida Grande'; font-size: 13.3333330154419px; line-height: 24px; background-color: #d6d3d6;">&#8217;&nbsp; @&#8217;</strong><strong style="color: #333333; font-family: Verdana, Arial, sans-serif, 'Lucida Grande'; font-size: 13.3333330154419px; line-height: 24px; background-color: #d6d3d6;">主机名称</strong><strong style="color: #333333; font-family: Verdana, Arial, sans-serif, 'Lucida Grande'; font-size: 13.3333330154419px; line-height: 24px; background-color: #d6d3d6;">&#8217;&nbsp; = password(&#8216;</strong><strong style="color: #333333; font-family: Verdana, Arial, sans-serif, 'Lucida Grande'; font-size: 13.3333330154419px; line-height: 24px; background-color: #d6d3d6;">新密码</strong><strong style="color: #333333; font-family: Verdana, Arial, sans-serif, 'Lucida Grande'; font-size: 13.3333330154419px; line-height: 24px; background-color: #d6d3d6;">&#8217;);<br />当然也可以直接update mysql.user set password=passoword('') where user='' and host='';<br />flush privileges<br />查看权限：<br /></strong><div>mysql&gt; show grants for user;<br />查看列级权限：<br /><div>&nbsp;SELECT * FROM mysql.columns_priv&nbsp;<br /><div>&#9312;权限的层级关系，就是指权限的适用范围。</div><div>&#9313;权限的最高层级是全局级，所谓全局级就是可以在任何数据库的任何数据表上进行操作。</div><div>&#9314;数据库级：只能在某个数据库上进行操作。</div><div>&#9315;表级：权限信息所在位置：数据库: mysql ?表: tables_priv "Table privileges"</div><div>&#9316;列级：权限信息所在位置：数据库: mysql ?表: columns_priv "Column privileges"</div><div>&#9317;子程序级：权限信息所在位置：数据库: mysql ?表: procs_priv "Procedure privileges"<br /><br />三　建库<br /><div><span style="color: #0000ff;">mysql&gt; create database db ;</span></div><div><span style="color: #0000ff;">Query OK, 1 row affected (0.00 sec)&nbsp;</span></div><div><span style="color: #0000ff;">mysql&gt; show create database db;</span></div><div><span style="color: #0000ff;">+----------+---------------------------------------------------------------+</span></div><div><span style="color: #0000ff;">| Database | Create Database &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |</span></div><div><span style="color: #0000ff;">+----------+---------------------------------------------------------------+</span></div><div><span style="color: #0000ff;">| db &nbsp; &nbsp; &nbsp; | CREATE DATABASE `db` /*!40100 DEFAULT CHARACTER SET latin1 */ |</span></div><div><span style="color: #0000ff;">+----------+---------------------------------------------------------------+</span></div><div><span style="color: #0000ff;">1 row in set (0.00 sec)</span><br /><span style="color: #0000ff;">mysql&gt;grant all on db.* to 'snowhill'@'%';</span><br /><div><span style="color: #0000ff;">flush PRIVILEGES;</span><br /><div><span style="color: #0000ff;">create table T(id smallint,name varchar(32));</span></div><div><span style="color: #0000ff;">CREATE TABLE T_1(ID SMALLINT,NAME VARCHAR(32)) ENGINE='MYISAM';<br /></span><div>create table t_2 (id smallint,name varchar(32)) ENGINE=innodb default charset=utf8;</div>查看建表语句：<br /><div><span style="color: #0000ff;">mysql&gt; show create table T;</span></div><div><span style="color: #0000ff;">+-------+----------------------------------------------------------------------------------------+</span></div><div><span style="color: #0000ff;">| Table | Create Table &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |</span></div><div><span style="color: #0000ff;">+-------+-----------------------------------------------------------------------------------------+</span></div><div><span style="color: #0000ff;">| T &nbsp; &nbsp; | CREATE TABLE `T` (</span></div><div><span style="color: #0000ff;">&nbsp; `id` smallint(6) DEFAULT NULL,</span></div><div><span style="color: #0000ff;">&nbsp; `name` varchar(32) DEFAULT NULL</span></div><div><span style="color: #0000ff;">) ENGINE=InnoDB DEFAULT CHARSET=latin1 |</span></div><div><span style="color: #0000ff;">+-------+------------------------------------------------------------------------------------------------+</span></div><div><span style="color: #0000ff;">1 row in set (0.00 sec)</span></div><div><span style="color: #0000ff;">&nbsp;</span></div><div><span style="color: #0000ff;">mysql&gt; show create table T_1;</span></div><div><span style="color: #0000ff;">+-------+-------------------------------------------------------------------------------------------------------+</span></div><div><span style="color: #0000ff;">| Table | Create Table &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|</span></div><div><span style="color: #0000ff;">+-------+-------------------------------------------------------------------------------------------------------+</span></div><div><span style="color: #0000ff;">| T_1 &nbsp; | CREATE TABLE `T_1` (</span></div><div><span style="color: #0000ff;">&nbsp; `ID` smallint(6) DEFAULT NULL,</span></div><div><span style="color: #0000ff;">&nbsp; `NAME` varchar(32) DEFAULT NULL</span></div><div><span style="color: #0000ff;">) ENGINE=MyISAM DEFAULT CHARSET=latin1 |</span></div><div><span style="color: #0000ff;">+-------+-------------------------------------------------------------------------------------------------------+</span></div><div><div>mysql&gt; show create table t_2;</div><div>+-------+--------------------------------------------------------------------------------------------------------+</div><div>| Table | Create Table &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|</div><div>+-------+---------------------------------------------------------------------------------------------------------+</div><div>| t_2 &nbsp; | CREATE TABLE `t_2` (</div><div>&nbsp; `id` smallint(6) DEFAULT NULL,</div><div>&nbsp; `name` varchar(32) DEFAULT NULL</div><div>) ENGINE=InnoDB DEFAULT CHARSET=utf8 |<br /><div>mysql&gt; show table status from db;<br />Mysql里的引擎是可以改的，更改语句如下：<br /><div>mysql&gt; alter table T_1 engine=innodb;</div><div>Query OK, 0 rows affected (0.02 sec)</div></div></div></div></div></div></div></div></div></div></div></div><img src ="http://www.cppblog.com/snowhill/aggbug/211954.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/snowhill/" target="_blank">snowhill</a> 2015-10-06 12:44 <a href="http://www.cppblog.com/snowhill/articles/211954.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>mysql windows 安装</title><link>http://www.cppblog.com/snowhill/articles/202702.html</link><dc:creator>snowhill</dc:creator><author>snowhill</author><pubDate>Fri, 23 Aug 2013 09:06:00 GMT</pubDate><guid>http://www.cppblog.com/snowhill/articles/202702.html</guid><wfw:comment>http://www.cppblog.com/snowhill/comments/202702.html</wfw:comment><comments>http://www.cppblog.com/snowhill/articles/202702.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/snowhill/comments/commentRss/202702.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/snowhill/services/trackbacks/202702.html</trackback:ping><description><![CDATA[<div abs_visibility="true">一　安装数据库服务<br />mysqld --install mysqlxy<br />二　启动数据库<br />net start mysqlxy<br />三　查询版本号 
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 21.54%; padding-right: 5px; height: 122px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif" /><span style="color: #000000">mysql</span><span style="color: #808080">&gt;</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">select</span><span style="color: #000000">&nbsp;version();<br /><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif" /></span><span style="color: #808080">+</span><span style="color: #008080">--</span><span style="color: #008080">----------------+</span><span style="color: #008080"><br /><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif" /></span><span style="color: #808080">|</span><span style="color: #000000">&nbsp;version()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080">|</span><span style="color: #000000"><br /><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif" /></span><span style="color: #808080">+</span><span style="color: #008080">--</span><span style="color: #008080">----------------+</span><span style="color: #008080"><br /><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif" /></span><span style="color: #808080">|</span><span style="color: #000000">&nbsp;</span><span style="color: #800000; font-weight: bold">5.1</span><span style="color: #000000">.</span><span style="color: #800000; font-weight: bold">71</span><span style="color: #808080">-</span><span style="color: #000000">community&nbsp;</span><span style="color: #808080">|</span><span style="color: #000000"><br /><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif" /></span><span style="color: #808080">+</span><span style="color: #008080">--</span><span style="color: #008080">----------------+</span><span style="color: #008080"><br /><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif" /></span><span style="color: #800000; font-weight: bold">1</span><span style="color: #000000">&nbsp;row&nbsp;</span><span style="color: #808080">in</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">set</span><span style="color: #000000">&nbsp;(</span><span style="color: #800000; font-weight: bold">0.05</span><span style="color: #000000">&nbsp;sec)</span></div><br />四　查询用户<br />mysql&gt; use mysql<br />mysql&gt; select host,user,password from user;<br />+-----------+------+----------+<br />| host&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | user | password |<br />+-----------+------+----------+<br />| localhost | root |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br />| 127.0.0.1 | root |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br />| localhost |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br />+-----------+------+----------+<br />五　建立用户和建库<br />
<p>mysql&gt; create database tytx character set gbk;<br />Query OK, 1 row affected (0.01 sec)</p>
<p>mysql&gt; grant all on tytx.* to <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#116;&#121;&#116;&#120;&#64;&#108;&#111;&#99;&#97;&#108;&#104;&#111;&#115;&#116;">tytx@localhost</a> identified by 'mysql';<br />Query OK, 0 rows affected (0.05 sec)<br />mysql&gt; show create table student;<br />------------------------------------------------------------------------------+<br />| Table&nbsp;&nbsp; | Create Table<br />------------------------------------------------------------------------------+<br />| student | CREATE TABLE `student` (<br />&nbsp; `id` int(11) DEFAULT NULL,<br />&nbsp; `name` char(12) DEFAULT NULL,<br />&nbsp; `class` char(10) DEFAULT NULL,<br />&nbsp; `grade` char(2) DEFAULT NULL<br />) ENGINE=InnoDB DEFAULT CHARSET=gbk |<br />+---------+-------------------------------------------------------------------------<br />这里可以看出所用的数据库引擎和字符集编码。<br />--查看表的状态<br />mysql&gt; show table status from tytx where name='STUDENT';<br />六　备份<br />D:\&gt;mysqldump -utytx -pmysql tytx &gt;d:\mysql_2.dmp<br />&nbsp;这样备出来的是一个文本文件。可以压缩一下。</p>
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 44.2%; padding-right: 5px; height: 423px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px" abs_visibility="true"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #000000" abs_visibility="true">@echo on<br />cd d:\mysql\dmp\<br />del 15.sql.gz<br />move 14.sql.gz 15.sql.gz<br />move 13.sql.gz 14.sql.gz<br />move 12.sql.gz 13.sql.gz<br />move 11.sql.gz 12.sql.gz<br />move 10.sql.gz 11.sql.gz<br />move 9.sql.gz 10.sql.gz<br />move 8.sql.gz 9.sql.gz<br />move 7.sql.gz 8.sql.gz<br />move 6.sql.gz 7.sql.gz<br />move 5.sql.gz 6.sql.gz<br />move 4.sql.gz 5.sql.gz<br />move 3.sql.gz 4.sql.gz<br />move 2.sql.gz 3.sql.gz<br />move 1.sql.gz 2.sql.gz<br />set v_time=%date:~0,10%<br />set v_file=d:\mysqldmp\<br />mysqldump -utytx -pmysql tytx|gzip &gt;1.sql.gz<br /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span></div>
<p>还原<br />gunzip &lt; 1.sql.gz | mysql -uusername -ppassword databasename<br /><br /></p></div><img src ="http://www.cppblog.com/snowhill/aggbug/202702.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/snowhill/" target="_blank">snowhill</a> 2013-08-23 17:06 <a href="http://www.cppblog.com/snowhill/articles/202702.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>