<?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>pastbedti.me &#187; MySQL</title>
	<atom:link href="http://www.pastbedti.me/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pastbedti.me</link>
	<description>About ruby, rails, postgresql and stuff....</description>
	<lastBuildDate>Wed, 01 Jun 2011 20:09:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Reset/recover MySQL root password in freebsd</title>
		<link>http://www.pastbedti.me/2008/11/resetrecover-mysql-root-password-in-freebsd/</link>
		<comments>http://www.pastbedti.me/2008/11/resetrecover-mysql-root-password-in-freebsd/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 14:49:16 +0000</pubDate>
		<dc:creator>Mathias Stjernström</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Hosting]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[passwords]]></category>

		<guid isPermaLink="false">http://www.pastbedti.me/?p=219</guid>
		<description><![CDATA[This is a little memory note for my self and hopefully it can help someone else how to reset MySQL root password. It happens that we are asked to do some work on our customers dedicated servers and when that happens it&#8217;s not that uncommon that there is not a single person alive that has [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is a little memory note for my self and hopefully it can help someone else how to reset MySQL root password.</em> </p>
<p>It happens that we are asked to do some work on our customers dedicated servers and when that happens it&#8217;s not that uncommon that there is not a single person alive that has the root password for the MySQL server. When that happen it&#8217;s good to know how to reset it <img src='http://www.pastbedti.me/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>This post is about how simple it&#8217;s to reset MySQL&#8217;s root password under FreeBSD.<br />
<span id="more-219"></span></p>
<p>The first step is to start MySQL without it&#8217;s grant tables.</p>
<p>Under FreeBSD you pass your mysql startup parameters in /etc/rc.conf</p>
<p>Add the following to /etc/rc.conf. We add &#8211;skip-networking to because we do not want someone from the outside to connect without passwords to our server.</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #007800;">mysql_enable</span>=<span style="color: #ff0000;">&quot;YES&quot;</span><br />
<span style="color: #007800;">mysql_args</span>=<span style="color: #ff0000;">&quot;--skip-grant-tables --skip-networking&quot;</span></div></td></tr></tbody></table></div>
<p>And then restart MySQL with the following command.</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc.d<span style="color: #000000; font-weight: bold;">/</span>mysql-server restart</div></td></tr></tbody></table></div>
<p>When MySQL comes back online it&#8217;s running without grant tables which means that you do not have to use a password to connect to it (no one has to).</p>
<p>Simply connect as root (without password) and issue the following SQL query.</p>
<div class="codecolorer-container sql twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="sql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&gt;</span> mysql <span style="color: #66cc66;">-</span>u root mysql<br />
<br />
mysql<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">UPDATE</span> mysql<span style="color: #66cc66;">.</span><span style="color: #993333; font-weight: bold;">USER</span> <span style="color: #993333; font-weight: bold;">SET</span> Password<span style="color: #66cc66;">=</span>PASSWORD<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'&lt;Your new password&gt;'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #993333; font-weight: bold;">USER</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'root'</span>;</div></td></tr></tbody></table></div>
<p>Now we are almost done. Just comment the skip-grant-tables line from rc.conf and restart MySQL and you should have a brand new root password. </p>
<p>For for other *nix users the process is the same except from how you pass your MySQL params to MySQL at startup. You can also start MySQL manually with something like this.</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;</span>path to safe_mysqld<span style="color: #000000; font-weight: bold;">&gt;/</span>safe_mysqld <span style="color: #660033;">--user</span>=mysql <span style="color: #660033;">--skip-grant-tables</span> <span style="color: #660033;">--skip-networking</span> <span style="color: #000000; font-weight: bold;">&amp;</span></div></td></tr></tbody></table></div>
<p>Cheers! </p>
]]></content:encoded>
			<wfw:commentRss>http://www.pastbedti.me/2008/11/resetrecover-mysql-root-password-in-freebsd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

