How to reset the mySQL admin password

怎么重置MYSQL 的管理员密码

在linux 环境下,重置root 密码主要通过以下几个方面:

How to reset the mySQL admin password

In a Unix environment, the procedure for resetting the root password is as follows:

1. Log on to your system as either the Unix root user or as the same user that the mysqld server runs as.

2. Locate the .pid file that contains the server’s process ID. The exact location and name of this file depend on your distribution, hostname, and configuration. Common locations are /var/lib/mysql/, /var/run/mysqld/, and /usr/local/mysql/data/. Generally, the filename has the extension of .pid and begins with either mysqld or your system’s hostname.

You can stop the MySQL server by sending a normal kill (not kill -9) to the mysqld process, using the pathname of the .pid file in the following command:

shell> kill `cat /mysql-data-directory/host_name.pid`

Note the use of backticks rather than forward quotes with the cat command; these cause the output of cat to be substituted into the kill command.

3. Restart the MySQL server with the special –skip-grant-tables option:

shell> mysqld_safe –skip-grant-tables &

4. Set a new password for the root@localhost MySQL account:

shell> mysqladmin -u root flush-privileges password “newpwd”

Replace “newpwd” with the actual root password that you want to use.

5. You should be able to connect using the new password.

Related posts:

  1. Ubuntu Server apt-get install Apache2 & PHP5 & MySQL5
  2. VPS Ubuntu 上安装配置 Postfix + Courier (初级篇)
  3. ubuntu server 8 上建立虚拟主机 和 目录文件夹实现用户验证
此条目发表在 Linux-Server, 代码人生 分类目录,贴了 , 标签。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已被标记为 *

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word