搜索
首页数据库mysql教程MySQL忘记root密码的解决方法_MySQL

bitsCN.com
MySQL忘记root密码的解决方法 Linux下的解决方法:    一. MySQL密码的恢复方法之一     如果忘记了MySQL的root密码,可以用以下方法重新设置:     1. KILL掉系统里的MySQL进程;        killall -TERM mysqld     2. 用以下命令启动MySQL,以不检查权限的方式启动;        safe_mysqld --skip-grant-tables &      3. 然后用空密码方式使用root用户登录 MySQL;        mysql -u root     4. 修改root用户的密码;        mysql> update mysql.user set password=PASSWORD('新密码') where User='root';        mysql> flush privileges;        mysql> quit     重新启动MySQL,就可以使用新密码登录了。  二. MySQL密码的恢复方法二     有可能你的系统没有 safe_mysqld 程序(比如我现在用的 ubuntu操作系统, apt-get安装的mysql) , 下面方法可以恢复     1. 停止mysqld;        /etc/init.d/mysql stop       (您可能有其它的方法,总之停止mysqld的运行就可以了)     2. 用以下命令启动MySQL,以不检查权限的方式启动;        mysqld --skip-grant-tables &      3. 然后用空密码方式使用root用户登录 MySQL;        mysql -u root     4. 修改root用户的密码;        mysql> update mysql.user set password=PASSWORD('newpassword') where User='root';        mysql> flush privileges;        mysql> quit     重新启动MySQL        /etc/init.d/mysql restart 就可以使用新密码 newpassword 登录了。    Windows下的解决方法:  1、编辑MySQL的配置文件:my.ini 一般在MySQL安装目录下有my.ini即MySQL的配置文件。 在此配置文件的最后添加如下一行: skip-grant-tables 保存退出编辑。  2、然后重启MySQL服务 在命令行下执行: net stop MySQL net start MySQL  3、设置新的ROOT密码 然后再在命令行下执行: MySQL -u root -p MySQL或mysql -u root -p 直接回车无需密码即可进入数据库了。  此时,在命令行下执行 use mysql; 现在我们执行如下语句把root密码更新为: update user set password=password("root") where user="root"; (注意:此时不用使用mysqladmin -u root -p password '你的新密码'这条命令修改密码,因为'skip-grant-tables'配置, 不信的话,你可以试用一下,它肯定会报如下所示的错误:  F:/Documents and Settings/long>mysqladmin -u root -p password 'root' Enter password: Warning: single quotes were not trimmed from the password by your command line client, as you might have expected. mysqladmin: You cannot use 'password' command as mysqld runs with grant tables disabled (was started with --skip-grant-tables). Use: "mysqladmin flush-privileges password '*'" instead) exit 退出MySQL。  4、还原配置文件并重启服务    然后修改MySQL配置文件把刚才添加的那一行'skip-grant-tables'删除。 再次重起MySQL服务,密码修改完毕。 用新密码root试一下吧,又能登入重新进入mysql了. bitsCN.com

声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
如何在MySQL中删除或修改现有视图?如何在MySQL中删除或修改现有视图?May 16, 2025 am 12:11 AM

todropaviewInmySQL,使用“ dropviewifexistsview_name;” andTomodifyAview,使用“ createOrreplaceViewViewViewview_nameAsSelect ...”。whendroppingaview,asew dectivectenciesanduse和showcreateateviewViewview_name;“ tounderStanditSsstructure.whenModifying

MySQL视图:我可以使用哪些设计模式?MySQL视图:我可以使用哪些设计模式?May 16, 2025 am 12:10 AM

mySqlViewScaneFectectialized unizedesignpatternslikeadapter,Decorator,Factory,andObserver.1)adapterPatternadaptSdataForomDifferentTablesIntoAunifiendView.2)decoratorPatternenhancateDataWithCalcalcualdCalcalculenfields.3)fieldfields.3)

在MySQL中使用视图的优点是什么?在MySQL中使用视图的优点是什么?May 16, 2025 am 12:09 AM

查看InMysqlareBeneForsImplifyingComplexqueries,增强安全性,确保dataConsistency,andOptimizingPerformance.1)他们simimplifycomplexqueriesbleiesbyEncapsbyEnculatingThemintoreusableviews.2)viewsEnenenhancesecuritybyControllityByControllingDataAcces.3)

如何在MySQL中创建一个简单的视图?如何在MySQL中创建一个简单的视图?May 16, 2025 am 12:08 AM

toCreateAsimpleViewInmySQL,USEthecReateaTeviewStatement.1)defitEtheetEtheTeViewWithCreatEaTeviewView_nameas.2)指定usethectstatementTorivedesireddata.3)usethectStatementTorivedesireddata.3)usetheviewlikeatlikeatlikeatlikeatlikeatlikeatable.views.viewssimplplifefifydataaccessandenenanceberity but consisterfort,butconserfort,consoncontorfinft

MySQL创建用户语句:示例和常见错误MySQL创建用户语句:示例和常见错误May 16, 2025 am 12:04 AM

1)foralocaluser:createUser'localuser'@'@'localhost'Indidendify'securepassword'; 2)foraremoteuser:creationuser's creationuser'Remoteer'Remoteer'Remoteer'Remoteer'Remoteer'Remoteer'Remoteer'Remoteer'Rocaluser'@'localhost'Indidendify'seceledify'Securepassword'; 2)

在MySQL中使用视图的局限性是什么?在MySQL中使用视图的局限性是什么?May 14, 2025 am 12:10 AM

mysqlviewshavelimitations:1)他们不使用Supportallsqloperations,限制DatamanipulationThroughViewSwithJoinSorsubqueries.2)他们canimpactperformance,尤其是withcomplexcomplexclexeriesorlargedatasets.3)

确保您的MySQL数据库:添加用户并授予特权确保您的MySQL数据库:添加用户并授予特权May 14, 2025 am 12:09 AM

porthusermanagementInmysqliscialforenhancingsEcurityAndsingsmenting效率databaseoperation.1)usecReateusertoAddusers,指定connectionsourcewith@'localhost'or@'%'。

哪些因素会影响我可以在MySQL中使用的触发器数量?哪些因素会影响我可以在MySQL中使用的触发器数量?May 14, 2025 am 12:08 AM

mysqldoes notimposeahardlimitontriggers,butacticalfactorsdeterminetheireffactective:1)serverConfiguration impactactStriggerGermanagement; 2)复杂的TriggerSincreaseSySystemsystem load; 3)largertablesslowtriggerperfermance; 4)highConconcConcrencerCancancancancanceTigrignecentign; 5); 5)

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热工具

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

SublimeText3 英文版

SublimeText3 英文版

推荐:为Win版本,支持代码提示!

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )专业的PHP集成开发工具

安全考试浏览器

安全考试浏览器

Safe Exam Browser是一个安全的浏览器环境,用于安全地进行在线考试。该软件将任何计算机变成一个安全的工作站。它控制对任何实用工具的访问,并防止学生使用未经授权的资源。