Change and Reset MySQL root Password改变和重置MySQL的root密码
Other then the ways specified然后其他的方式指定 here这里 to reset and change the root password for mySQL database in the case that the password is forgotten or lost, the following instructions explain in details the alternative way at the last part of the guide, where no additional file needs to be created:重置和改变了root密码为MySQL数据库,在案件的密码是忘记或遗失,下列指示解释,在细节的替代方式,在最后部分的指导,如果没有额外的文件需要创建:
- Login as root to the Windows or Unix-like (Unix, Linux or BSD) machine with the MySQL server.以root身份登录到Windows或Unix一样(的Unix , Linux或BSD的)机器与MySQL服务器。
- Stop the MySQL server by using either of the following command:停止MySQL服务器使用的下列命令:
Linux: /etc/rc.d/init.d/mysql stop Linux作业系统:在/ etc / rc.d / init.d /的MySQL的停止
FreeBSD: /usr/local/etc/rc.d/mysql-server.sh stop FreeBSD作业系统:在/ usr / local的/ etc / rc.d / MySQL的- server.sh停止 - Open the mysql server startup script (ie mysql-server.sh - the file executed to start or stop MySQL server.打开MySQL服务器启动脚本(即MySQL的- server.sh -该文件执行的开始或停止M ySQL服务器。
- Add –skip-grant-tables to the end of the line that contains the mysqld_safe command as its parameter.添加-跳过-赠款表到去年底,该行包含mysqld_safe命令作为参数。
- Start MySQL server with the following command:启动MySQL服务器与下面的命令:
Linux: /etc/rc.d/init.d/mysql start Linux作业系统:在/ etc / rc.d / init.d /的MySQL的开始
FreeBSD: /usr/local/etc/rc.d/mysql-server.sh start FreeBSD作业系统:在/ usr / local的/ etc / rc.d / MySQL的- server.sh开始 - Alternatively, start the MySQL server directly and skip the editing with the following command:或者,启动MySQL服务器直接跳到编辑与以下命令:
mysqld_safe –skip-grant-tables & mysqld_safe -跳过-赠款表&
Depending on your path environment, you may need to point to the correct directory where mysqld_safe is instead.根据您的PATH环境,您可能需要指向正确的目录下mysqld_safe是不是。
- Run the following commands to login as the mysql user and connect to mysql user/permission database:运行下面的命令登录作为MySQL用户并连接到MySQL用户/许可数据库:
# mysql -u root mysql # MySQL的中美根的MySQL
- Run the update queries to change the MySQL password:运行更新查询来改变MySQL的密码:
mysql> UPDATE user SET Password=PASSWORD(’newrootpassword’) WHERE User=’root’; MySQL的>更新用户设置密码=密码( ' newrootpassword ' )其中user = '根' ;
mysql> FLUSH PRIVILEGES; MySQL的>冲水特权;Note: Replace newrootpassword with the new root password for MySQL server.注:取代newrootpassword与新的root密码为MySQL服务器。 Flush Privileges is needed to making the password change effect immediately.冲水特权,是需要作出更改密码立即生效。
- Exit mysql database client by typing exit.退出MySQL数据库的客户端上键入exit 。
- Stop MySQL server with commands listed at step 2.停止MySQL服务器与命令列在第2步。
- Open the mysql server startup script edit in step 3 again and remove the –skip-grant-tables parameter that has been added.打开MySQL服务器启动脚本编辑在第3步,再删除-跳过-赠款表参数已添加。
- Start MySQL server by using command from step 5 or 6.启动MySQL服务器使用命令从步骤5或6 。
For Redhat Linux users, use the following instructions as the root user of Redhat Linux machine:为Redhat的Linux用户,请使用以下的指示,作为root用户的版RedHat Linux的机:
- Stop MySQL process by using command:停止MySQL的过程中所使用的命令:
# killall mysqld # killall mysqld
- Start the MySQL server with following options:启动MySQL服务器与下列选项:
# /usr/libexec/mysqld -Sg –user=root & #是/ usr / libexec / mysqld -双桂用户=根&
- Start the MySQL client:启动MySQL客户端:
# mysql # MySQL的
You should see the following message:你应该看到以下讯息:
Welcome to the MySQL monitor.欢迎您到MySQL的监察。 Commands end with ; or g.命令结束;或g.
Your MySQL connection id is 1 to server version: 3.xx.xx您的MySQL连接ID是1至服务器版本: 3.xx.xxType ‘help;’ or ‘h’ for help.键入'帮助; '或' h '的帮助。 Type ‘c’ to clear the buffer.类型的' C ' ,以清除缓冲区。
mysql> MySQL的>
- Use mysql database:使用MySQL数据库:
mysql> USE mysql MySQL的>中使用MySQL
You should see the following message:你应该看到以下讯息:
Reading table information for completion of table and column names读表信息,为完成表和列名
You can turn off this feature to get a quicker startup with -A您可以关闭此功能,以获得更快的启动与- 1Database changed数据库改变
- Then, update the password for the root user with the following command:然后,更新密码,为root用户与下列命令:
UPDATE user SET password=password(”newpassword”) WHERE user=”root”;更新用户设置密码=密码( “ newpassword ” )凡用户= “根” ;
Replace newpassword with your desired password.取代newpassword与您想要的密码。 You should see the following message:你应该看到以下讯息:
Query OK, 2 rows affected (0.03 sec)查询确定,二行的影响( 0.03秒)
Rows matched: 2 Changed: 2 Warnings: 0行匹配: 2改变: 2警告: 0Rows affected may be different, but the Query OK should be there.行受影响的可能有所不同,但查询确定,应该有。
- Flush the database privileges to reload it in order to make the changes effective:刷新数据库的特权,重新载入它,以使有效的变化:
mysql> flush privileges; MySQL的>冲水特权;
You should get the following result:你应得的结果如下:
Query OK, 0 rows affected (0.02 sec)查询确定, 0行受影响( 0.02秒)
- Exit the MySQL client by typing exit.退出MySQL客户端上键入exit 。
- Kill the MySQL server process by typing killall mysqld.杀死MySQL服务器的过程中输入killall mysqld 。
- Then start MySQL again:然后启动MySQL的再次:
/etc/init.d/mysqld start / etc / init.d /的mysqld启动
IMPORTANT : This is a machine translated page which is provided "as is" without warranty. 重要说明 :这是一个机器翻译网页是“按原样”提供的担保。 Machine translation may be difficult to understand.机器翻译可能很难理解。 Please refer to请参阅 original English article英文原版的文章 whenever possible.只要有可能。
Share and contribute or get technical support and help at分享和贡献,或取得技术的支持和帮助,在 My Digital Life Forums 我的数字生活论坛 . 。
Related Articles相关文章
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 - Part 3安装Web服务器在FreeBSD的6.0与2.2的Apache , MySQL 5.0的和PHP 5 -第3部分
- Reset the Root Password of MySQL Server重置root密码的MySQL服务器
- Install Web Server in Windows XP with Apache2, PHP5 and MySQL4 - Part 4安装Web服务器在Windows XP的Apache2 , php5和mysql4 -第4部分
- Check and Optimize MySQL Database Automatically with Crontab/Cron检查和优化MySQL数据库自动与crontab /玉米
- How to Recover and Reset Gmail (Google Account) Password如何恢复和复位的Gmail ( Google帐户)的密码
- How to Reset AdSense Password Not Associated with Google Account如何重置AdSense密码不能与Google相关的帐户
- How to Reset WordPress Password to Recover Forgotten Secret如何重置的WordPress密码,以收回被遗忘的秘密
- Change Oracle Database User Password改变Oracle数据库的用户密码
- Apple iPhone Root Password and Mobile User Password苹果iphone root密码和移动用户密码
- Fix for Munin MySQL Monitoring Plugin Graph Not Showing or Blank修复munin MySQL的监测插件图无法显示或空白



















June 6th, 2006 18:18 2006年6月6日18时18分
[...] Alternatively, on any platform, mysql client can be used to set the new password, althought it’s less secure way of resetting the password (detailed instruction here): [...] [ … … ]另外,任何平台上, MySQL客户端可以用来设置新的密码,虽然它的安全性较低的方式重设密码(详细指示,在这里) : [ … … ]
July 9th, 2006 12:05 2006年7月9日12时05分
I wanna reset my ZXDSL 831 ADSL Modemn我想重设我的zxdsl 831的ADSL modemn
Plz tell me the way how to reset it plz告诉我如何重置
I need to do that right now我需要这样做的权利,现在
Best Rgds最佳rgds
dugger(vincitore) dugger ( vincitore )
December 19th, 2006 14:54 2006年12月19日14时54分
[...] Re: Help me retrieve my password Try this link… Change and Reset MySQL root Password [ … … ]回复:帮我找回我的密码尝试此连结…变化和重置MySQL的root密码
April 23rd, 2007 08:23 2007年4月23日8时23分
[...] Change and Reset MySQL root Password » My Digital Life (tags: mysql administration) No Tags Gelesen: 2 / heute: 2 [...] [ … … ]的变化和重置MySQL的root密码»我的数位生活(标签: MySQL的政府)没有标签gelesen : 2 / heute : 2 [ … … ]
May 5th, 2008 16:52 2008年5月5日16时52分
[...] judulnya), setelah googling cuma dapat cara untuk mereset dan mengganti password MySQL di UNIX-like di sini. [ … … ] judulnya ) , setelah使用Google cuma应该象限定mereset丹mengganti密码MySQL的直接投资的UNIX一样,邸四逆。 Wah, perlu sedikit modifikasi ni … Berikut cara2 yang saya lakukan: 1.议员, perlu sedikit modifikasi倪… berikut cara2杨saya lakukan : 1 。 Kill proses MySQL [...]杀死散文MySQL的[ … … ]
July 3rd, 2008 05:46 2008年7月3日5时46分
On ubuntu, command is mysqld_safe –-skip-grant-tables &关于Ubuntu的,指挥是mysqld_safe -跳过-赠款表&
Extra dash is required so mysql can parse it correctly.短跑是额外的要求,以便MySQL的可以解析正确的。