Home >Database >Mysql Tutorial >mysql密码忘记时如何修改密码(Linux&Windows)_MySQL

mysql密码忘记时如何修改密码(Linux&Windows)_MySQL

WBOY
WBOYOriginal
2016-06-01 13:13:21921browse
一,Linux篇1,停掉mysql服务:service mysql stop;2,修改my.cnf文件,可以通过find / -name my.cnf来找到文件,里面内容包含
[mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockuser=mysql
即是我们要找的文件,在user-mysql下加入:skip-grant-tables,保存后退出3,mysqld restart;4,service mysql start.5,输入mysql即可进入mysql!二,Windows篇1、首先停止正在运行的MySQL进程>net stop mysql如未加载为服务,可直接在进程管理器或者服务中进行关闭。2、以安全模式启动MySQL进入mysql目录在命令行下运行>d:>cd xampp/mysql/bin >mysqld.exe --skip-grant-tables3、完成以后就可以不用密码进入MySQL了>mysql -u root -p提示输入密码时直接回车即可。4、更改密码>use mysql>update user set Password=password('新密码') where User='root';>flush privileges;5、启动MySQL服务在任务管理器里关闭所有MySQL的进程,使用下面的命令启动。>net start mysqlmysqladmin-u root -p shutdown
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn