﻿<?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++博客-八叶草(徐怀移)-随笔分类-mysql</title><link>http://www.cppblog.com/byc/category/19788.html</link><description>学习资料记录</description><language>zh-cn</language><lastBuildDate>Fri, 10 Aug 2012 12:11:25 GMT</lastBuildDate><pubDate>Fri, 10 Aug 2012 12:11:25 GMT</pubDate><ttl>60</ttl><item><title>mysql 多实例</title><link>http://www.cppblog.com/byc/archive/2012/08/10/186829.html</link><dc:creator>八叶草</dc:creator><author>八叶草</author><pubDate>Fri, 10 Aug 2012 07:24:00 GMT</pubDate><guid>http://www.cppblog.com/byc/archive/2012/08/10/186829.html</guid><wfw:comment>http://www.cppblog.com/byc/comments/186829.html</wfw:comment><comments>http://www.cppblog.com/byc/archive/2012/08/10/186829.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/byc/comments/commentRss/186829.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/byc/services/trackbacks/186829.html</trackback:ping><description><![CDATA[mkdir /var/lib/mysql_new<br />mysql_install_db --datadir=/var/lib/mysql_new --user=mysql<br /><span style="font-family: 宋体; mso-ascii-theme-font: minor-fareast; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast; mso-bidi-font-size: 10.5pt"><strong><br /><br />vi /etc/my.cnf 添加<br />
<p>&nbsp;</p>
<p>[mysqld_multi]<br />mysqld=/usr/bin/mysqld_safe<br />mysqladmin=/usr/bin/mysqladmin<br />log=/var/log/mysqld_multi.log<br />user = multi_admin<br />password = multipass</p>
<p><br />[mysqld1]<br />datadir=/var/lib/mysql_new<br />socket=/var/lib/mysql_new/mysql.sock<br />port=4000<br />pid-file=/var/lib/mysql_new/mysql.pid<br />user=mysql</p>
<p><br /><br />多实例启动<span lang="EN-US"><o:p></o:p></span></strong></span> <br /><span style="font-family: 宋体; mso-ascii-theme-font: minor-fareast; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast; mso-bidi-font-size: 10.5pt" lang="EN-US">mysqld_multi start 1</span><br /><br /><span style="font-family: 宋体; mso-ascii-theme-font: minor-fareast; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast; mso-bidi-font-size: 10.5pt"><strong>关闭<span lang="EN-US">MySQL</span>多实例</strong></span><br /><span style="font-family: 宋体; mso-ascii-theme-font: minor-fareast; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast; mso-bidi-font-size: 10.5pt" lang="EN-US"><strong>mysqld_multi stop 1</strong></span><br /><br /><strong>查看<span lang="EN-US">MySQL</span>端口启动状态</strong><br /><span><strong>netstat -ntlp | grep mysqld　　　<br /><br />查看<span lang="EN-US">MySQL</span>实例进程</strong></span><br /><span><strong>ps -ef | grep mysql　　　　　<br /><br />通过port连接<br />mysql -u root -h 127.0.0.1 -P 4000</strong></span> <br />通过sock<br />mysql -u root -S&nbsp;/var/lib/mysql_new/mysql.sock -p <br /><br /><br /><br />faq<br />my.cnf-[mysqld_multi]设置的user和password是用来关闭数据库实例的，根据配置中的用户名和密码授权该用户shutdown权限<br />mysql&nbsp;&nbsp;-S /var/lib/mysql_new/mysql.sock<br />mysql&gt; grant shutdown on *.* to multi_admin@'localhost' identified by 'multipass'; <br /></p><img src ="http://www.cppblog.com/byc/aggbug/186829.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/byc/" target="_blank">八叶草</a> 2012-08-10 15:24 <a href="http://www.cppblog.com/byc/archive/2012/08/10/186829.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>