mysql 重置密码模式_mysql--重置密码
解決Mysql忘記密碼:
1、首先停止正在運(yùn)行的MySQL進(jìn)程:[root@cml5?~]#?systemctl?stop?mysqld
2、以安全模式啟動(dòng)MySQL:[root@cml5?~]#?/usr/local/mysql/bin/mysqld_safe--skip-grant-tables?&
##或者在my.cnf文件下添加,執(zhí)行完后就刪除掉
skip-grant-tables[root@cml5?~]#?cat?/etc/my.cnf
[mysqld]
datadir=/usr/local/mysql/mydata
socket=/usr/local/mysql/mysql.sock
log_bin=/usr/local/mysql/mydata/mysql-bin
server-id=1
skip-grant-tables
然后重啟mysql
進(jìn)入mysql(免密碼)
然后修改密碼;
3、完成以后就可以免密進(jìn)入MySQL了,然后修改密碼:
(3)運(yùn)行 /usr/local/mysql/bin/mysql -u root -p 按Enter鍵進(jìn)入[root@cml5?~]#??/usr/local/mysql/bin/mysql?-u?root?-p
mysql>?use?mysql;
mysql>?update?user?set?password=password('123')?where?user='root'?and?host='localhost';
##假如是mysql5.7之后的就password字段改成了authentication_string:
mysql>?update?user?set?authentication_string=password('redhat')?where?user='root'and?host='localhost';
mysql5.7以上版本-->????UPDATE?user?SET?authentication_string=PASSWORD("root")?WHERE?User="root";
mysql>?flush?privileges;
mysql>?ALTER?user?'root'@'localhost'?identified?by?'redhat';
Query?OK,?0?rows?affected?(0.00?sec)
mysql>
mysql>?flush?privileges;
Query?OK,?0?rows?affected?(0.00?sec)
mysql>?show?databases;
+--------------------+
|?Database???????????|
+--------------------+
|?information_schema?|
|?mysql??????????????|
|?performance_schema?|
|?sys????????????????|
+--------------------+
4?rows?in?set?(0.00?sec)
ERROR?1820?(HY000):?You?must?reset?your?password?using?ALTER?USER?statement?before?executing?this?statement.
今天在MySql5.6操作時(shí)報(bào)錯(cuò):You?must?SET?PASSWORD?before?executing?this?statement解決方法,需要的朋友可以參考下
ERROR?1820?(HY000):?You?must?SET?PASSWORD?before?executing?this?statement
mysql>?create?database?yan1;
ERROR?1820?(HY000):?You?must?SET?PASSWORD?before?executing?this?statement
mysql>?SET?PASSWORD?=?PASSWORD('123456');
Query?OK,?0?rows?affected?(0.03?sec)
總結(jié)
以上是生活随笔為你收集整理的mysql 重置密码模式_mysql--重置密码的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: oracle_sqlserver和mys
- 下一篇: mysql数据库txt备份linux_l