<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://www.freebsdwiki.net/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.freebsdwiki.net/index.php?action=history&amp;feed=atom&amp;title=MySQL%2C_resetting_root_password</id>
		<title>MySQL, resetting root password - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://www.freebsdwiki.net/index.php?action=history&amp;feed=atom&amp;title=MySQL%2C_resetting_root_password"/>
		<link rel="alternate" type="text/html" href="http://www.freebsdwiki.net/index.php?title=MySQL,_resetting_root_password&amp;action=history"/>
		<updated>2026-05-01T18:11:22Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.18.0</generator>

	<entry>
		<id>http://www.freebsdwiki.net/index.php?title=MySQL,_resetting_root_password&amp;diff=11249&amp;oldid=prev</id>
		<title>Jimbo at 17:55, 14 May 2009</title>
		<link rel="alternate" type="text/html" href="http://www.freebsdwiki.net/index.php?title=MySQL,_resetting_root_password&amp;diff=11249&amp;oldid=prev"/>
				<updated>2009-05-14T17:55:40Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;The simplest method: stop the mysql service, temporarily restart it with the --skip-grant-tables option, log in with no password, reset it, then start it again normally.&lt;br /&gt;
&lt;br /&gt;
 % '''su'''&lt;br /&gt;
 server# '''/usr/local/etc/rc.d/mysql-server stop'''&lt;br /&gt;
 server# '''which mysqld'''&lt;br /&gt;
 /usr/local/bin/mysqld&lt;br /&gt;
 server# '''/usr/local/bin/mysqld --skip-grant-tables &amp;amp;'''&lt;br /&gt;
 server# '''mysql -u root'''&lt;br /&gt;
 mysql&amp;gt; '''UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';'''&lt;br /&gt;
 mysql&amp;gt; '''FLUSH PRIVILEGES;'''&lt;br /&gt;
 mysql&amp;gt; '''QUIT'''&lt;br /&gt;
 Bye&lt;br /&gt;
 server# '''killall mysqld'''&lt;br /&gt;
 server# '''/usr/local/etc/rc.d/mysql-server start'''&lt;br /&gt;
&lt;br /&gt;
The only problem with this is, you do temporarily have a window where someone else could log in with no password.  If that bugs you, you can start mysql with an init-file option instead.  First, create a file with the SQL command to update the root password:&lt;br /&gt;
&lt;br /&gt;
 UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;br /&gt;
&lt;br /&gt;
Now, assuming you've created that file at '''~/passwordreset.sql''', you can do the following:&lt;br /&gt;
&lt;br /&gt;
 % '''su'''&lt;br /&gt;
 server# '''sudo /etc/init.d/mysql stop'''&lt;br /&gt;
 server# '''which mysqld'''&lt;br /&gt;
 /usr/sbin/mysqld&lt;br /&gt;
 server# '''/usr/sbin/mysqld --init-file=~/passwordreset.sql &amp;amp;'''&lt;br /&gt;
 server# '''sudo killall mysqld'''&lt;br /&gt;
 server# '''sudo /etc/init.d/mysql start'''&lt;br /&gt;
&lt;br /&gt;
And this will reset your root password WITHOUT creating a window in which a bad guy might log in as root without having the root password.  (You will probably want to '''rm ~/passwordreset.sql''' after you're done, just to avoid giving anybody else any bad ideas.)&lt;br /&gt;
&lt;br /&gt;
[[Category:Common Tasks]]&lt;/div&gt;</summary>
		<author><name>Jimbo</name></author>	</entry>

	</feed>