mac下修改mysql的密碼
阿新 • • 發佈:2017-09-02
行修改 登錄管理 登錄mysql grant mysql base ref 管理員權限 mac 第一種
mysql版本:5.7.17
1.首先我們要關閉mysql服務
sudo /usr/local/mysql/support-files/mysql.server stop
2.我們要用安全模式啟動mysql
sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables
3.使用root賬號登錄mysql服務
/usr/local/mysql/bin/mysql u root
4.修改root賬號的密碼(其實這運行的是sql語句)
update mysql.user set authentication_string=password(‘qingyun1‘) where user=‘root‘ and Host = ‘localhost‘;
如果有必要,建議運行一下:flush privileges;
5.關閉安全模式,正常的重啟mysql
sudo /usr/local/mysql/support-files/mysql.server restart
6.正常的使用root賬號和密碼連接mysql
/usr/local/mysql/bin/mysql -u root -p
第二種
如果忘記密碼,強行修改: 1:?停止Mysql服務 sudo /usr/local/mysql/support-files/mysql.server stop 2:?進入終端輸入:cd /usr/local/mysql/bin/?回車後; 登錄管理員權限 sudo su?回車後; 輸入以下命令來禁止mysql驗證功能 ./mysqld_safe --skip-grant-tables &? 回車後mysql會自動重啟(偏好設置中mysql的狀態會變成running) 3. ? 輸入命令 ./mysql?回車後, 輸入命令 FLUSH PRIVILEGES; ?回車後,輸入命令 ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘你的新密碼‘; 第三種
1. 停止 mysql server. 通常是在 ‘系統偏好設置‘ > MySQL > ‘Stop MySQL Server‘ 或者: sudo /usr/local/mysql/support-files/mysql.server stop 2. 打開終端,輸入: sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables 3. 打開另一個新終端,輸入: sudo /usr/local/mysql/bin/mysql -u root UPDATE mysql.user SET authentication_string=PASSWORD(‘新密碼‘) WHERE User=‘root‘; FLUSH PRIVILEGES; \q 4. 重啟 sudo /usr/local/mysql/support-files/mysql.server restart *以上方法針對 mysql V5.7.9,
舊版的mysql請使用:UPDATE mysql.user SET Password=PASSWORD(‘新密碼‘) WHERE User=‘root‘;
這三種方法可以根據情況使用!
如果忘記密碼,強行修改: 1:?停止Mysql服務 sudo /usr/local/mysql/support-files/mysql.server stop 2:?進入終端輸入:cd /usr/local/mysql/bin/?回車後; 登錄管理員權限 sudo su?回車後; 輸入以下命令來禁止mysql驗證功能 ./mysqld_safe --skip-grant-tables &? 回車後mysql會自動重啟(偏好設置中mysql的狀態會變成running) 3. ? 輸入命令 ./mysql?回車後, 輸入命令 FLUSH PRIVILEGES; ?回車後,輸入命令 ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘你的新密碼‘; 第三種
1. 停止 mysql server. 通常是在 ‘系統偏好設置‘ > MySQL > ‘Stop MySQL Server‘ 或者: sudo /usr/local/mysql/support-files/mysql.server stop 2. 打開終端,輸入: sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables 3. 打開另一個新終端,輸入: sudo /usr/local/mysql/bin/mysql -u root UPDATE mysql.user SET authentication_string=PASSWORD(‘新密碼‘) WHERE User=‘root‘; FLUSH PRIVILEGES; \q 4. 重啟 sudo /usr/local/mysql/support-files/mysql.server restart *以上方法針對 mysql
mac下修改mysql的密碼