How to change mysql root password?

2011-05-11  来源:本站原创  分类:Database  人气:119 

If you forget your mysql root password, do not worry, you only need four steps will be able to solve the problem!

-------------------------------------------------- -------------------------------------------------- -----------------------------

Specific steps:

1, edit the MySQL configuration file:

windows environment:% MySQL_installdir% \ my.ini / / generally in the MySQL installation directory under the MySQL configuration file my.ini.
linux environment: / etc / my.cnf

In the configuration [MySQLd] section add the following line:

skip-grant-tables

Save and exit editor.

2, and then restart the MySQL Service

windows environment:

Execute the command line:
net stop MySQL
net start MySQL

linux environment:
/ Etc / init.d / MySQLd restart

3, set the new ROOT password

Execute the command line:
MySQL-u root-p MySQL
Directly enter without a password, you can enter the database.

Now we execute the following statement to update the root password is 123456:
Then execute the command line:

update user set password = PASSWORD ("123456") where user = 'root';

quit

Exit MySQL.

4, to restore the configuration file and restart the service

Then just modify the MySQL configuration file to add the line (skip-grant-tables) to delete.

Again, restart the MySQL service (step 2);

Modification is completed.

New password is 123456

-------------------------------------------------- -------------------------------------------------- ---------------------------

Several common ways to modify the mysql password

-------------------------------------------------- -------------------------------------------------- ---------------------------

Method 1: Use SET PASSWORD command

mysql-u root

mysql> SET PASSWORD FOR 'root' @ 'localhost' = PASSWORD ('newpass');

-------------------------------------------------- -------------------------------------------------- -----------------------------

Method 2: using mysqladmin

If the root password has been set, using the following method

mysqladmin-u root-p password "newpass"

Enter password: oldpass (here need the old password)

Note: If newpass = 123456,

Do not type in cmd, "123456", simply enter 123,456 on the line;

In this way, I tried the basic feasible;

-------------------------------------------------- -------------------------------------------------- ------------------------------

Method 3: Edit the user table directly using UPDATE

mysql-u root

mysql> use mysql;

mysql> UPDATE user SET Password = PASSWORD ('newpass') WHERE user = 'root';

mysql> FLUSH PRIVILEGES;

-------------------------------------------------- -------------------------------------------------- -------------------------------

Website:

1.web open Portal

2.linux commune

相关文章
  • Change mysql root password in several ways 2011-07-21

    Author: Xiaojian Bin | can be reproduced, reprinted, be sure to hyperlink when the form of articles marked the original source and author information and copyright Web site: http://www.xiaojb.com/archives/it/mysqlroot.shtml Method 1: In / usr / local

  • How to change mysql root password? 2011-05-11

    If you forget your mysql root password, do not worry, you only need four steps will be able to solve the problem! -------------------------------------------------- -------------------------------------------------- ----------------------------- Spec

  • Change mysql root password 2010-11-06

    Method 2: State in mysql: mysql> UPDATE user SET password = PASSWORD ('new_password') WHERE user = 'root'; mysql> FLUSH PRIVILEGES;

  • [Reserved] setting. Modification. Mysql root password reset 2010-03-16

    Set, modify, reset mysql root password Overview: This article describes how to set up, modify, reset (if you do not care forget root password) mysql root password, and often I use the mysqladmin command, often appear similar to the following informat

  • Changes on the mysql root password under linux problems encountered 2010-08-03

    Changes on the mysql root password under linux processes, can be found online a lot, probably is: # Killall mysqld / / interrupt the process currently running mysql # Mysqld_safe - skip-grant-tables & / / start in Safe Mode # Mysql / / no direct acce

  • MySQL root password reset three-step 2010-10-24

    If you forget the MySQL (and PHP with the best combination) ROOT password for MySQL (and PHP with the best combination) cause great inconvenience to use, but few friends would MySQL ROOT password reset, then complain ah, I have a deep feeling, close-

  • Mysql root password forgotten how to reset the root password 2010-09-02

    Mysql root password forgotten how to reset the root password Introduce a very useful mysql startup parameter - - skip-grant-tables. As the name suggests, is to start mysql does not start grant-tables, authorization form. What's the use? Of course, fo

  • MySQL root password to reset the three-step 2010-10-24

    If you forget to MySQL (and PHP with the best combination) ROOT password for MySQL (and PHP with the best combination) use causes great inconvenience, but few friends, will MySQL ROOT password reset, then complain ah, I have deep feelings, close-up a

  • How to change mysql database password 2011-03-22

    How to change mysql database password In the case of a known password, how to modify the mysql database password? 1 run cmd into the command line window; At the command line window, enter the mysql-uroot-proot (red logo is the original mysql password

  • MYSQL root password reset 2011-05-19

    Method One: MySQL provides access control to skip the command line parameters through the command line as a command to start MySQL server: safe_mysqld - skip-grant-tables & You can skip the MySQL access control, anyone can in the console as the admin

  • How to change mysql default password 2011-09-04

    mysql installation and if it does not change the default password is not secure, preferably immediately after the change mysql default password. To note that, mysql mysql password change is required in the root privileges, the average user can not ch

  • Forget MySQL Root Password 2011-09-15

    Forget MySQL Root Password 1. Stop the mysql service > / Etc / init.d / mysql stop 2. Start the server without password > Mysqld_safe - skip-grant-tables & 3. Connect to the mysql server > Mysql-u root 4. Setup new MYSQL root user password &g

  • mysql root password forget how to do 2011-09-21

    Turn http://zhaoshg.iteye.com/blog/380521 Forget MySQL ROOT password in MySQL using a very common problem, but have many friends and will not reset ROOT password, and what is much suffering, I have deep feelings, close-up and to share this article: 1

  • Ubuntu reset MySQL root password under the (transfer) 2010-12-28

    Learning ubuntu, install mysql root password after accidentally changed the password of non-normal by the following method to reset root password: mysql-server 5.1 version, as follows: 1.sudo vim / etc / mysql / my.cnf, in the [mysqld] section add th

  • Ubuntu to reset MySQL root password (rpm) 2010-12-28

    Learning ubuntu, install mysql root password after accidentally changed the password for non-normal by the following method to reset the root password: mysql-server 5.1 version, as follows: 1.sudo vim / etc / mysql / my.cnf, in the [mysqld] section a

  • mysql root password forgotten solution and restart 2011-01-23

    One. MySQL password recovery methods if you have forgotten MySQL root password, you can reset the following ways: 1. KILL off system in the MySQL process; killall -TERM mysqld 2 with the following command to start MySQL, do not check the permissions

  • Windews mysql root password is lost the next steps to solve 2011-05-22

    [Size = medium;] Mysql root password is lost troubleshooting steps: 1, stop mysql service (as an administrator, run the cmd command line) net stop mysql 2, into the install mysql bin directory, execute mysqld - skip-grant-tables 3, open a new cmd win

  • Mysql root password change 2010-10-10

    Mysql today made a experiment on the console when I use mysql-u root-p command when an error such ERROR 1045 (28000): Access denied for user 'root' @ 'localhost' (using password: YES) Means that the initial root password is empty approach: # Mysql-u

  • Change the MYSQL root password 2011-10-25

    First, select the mysql database as the default, then use the update command to update the password: mysql>use mysql; Database changed mysql>update user set password=PASSWORD('123456') where user='root'; Query OK, 0 rows affected (0.00 sec) Rows mat

  • Changes and to solve the Mysql root password in several ways 2011-05-05

    A method using phpmyadmin, this is the most simple, and modify the mysql database user table, but do not forget to use the PASSWORD function. Second method used mysqladmin, which is a special case of the previous declarations. mysqladmin-u root-p pas