windows下新安裝的mysql修改root password問題

來源:互聯網
上載者:User

標籤:

常用步驟:

1. 在my.ini中的mysqld下添加一行 

     skip-grant-tables

2.重啟mysql後直接進入後,用SQL直接修改password列:

C:\> net stop mysql
C:\> net start mysql
C:\> mysql
mysql>
mysql> use mysql
Database changed
mysql> UPDATE user SET Password=PASSWORD(‘newpassword‘) where USER=‘root‘;
ERROR 1054 (42S22): Unknown column ‘Password‘ in ‘field list‘

3. 但失敗了,原因是新版的mysql(5.7以後版本)這個列已經改成了"authentication_string", 所以在會失敗,正確的做法是

mysql> UPDATE user SET authentication_string=PASSWORD(‘newpassword‘) where USER=‘root‘;Query OK, 1 row affected, 1 warning (0.00 sec)Rows matched: 1  Changed: 1  Warnings: 1mysql>

4. 從my.ini中去掉之前加入的skip-grant-tables那行, 然後重啟mysql後,就可以用帶password的root登入了

E:\mysql>net stop mysqlMySQL 服務正在停止.MySQL 服務已成功停止。E:\mysql>net start mysqlMySQL 服務正在啟動 .MySQL 服務已經啟動成功。E:\mysql>mysql -u root -pEnter password: ***********Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.7.15Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql>

5. 這個時候還沒完,你還需要在正常模式下再修改一次密碼,否則殺也做了了,如下錯誤:

mysql> use mysqlERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

5. 而且提示很坑爹, 你必須用SET_PASSWORD, 而不是提示所說的ALTER USER

mysql> SET PASSWORD = PASSWORD(‘newpassword‘);Query OK, 0 rows affected, 1 warning (0.00 sec)mysql>use mysqlmysql>Database changed

 

windows下新安裝的mysql修改root password問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.