Home > Database > Mysql Tutorial > mysql 修改root密码的方法

mysql 修改root密码的方法

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 15:03:38
Original
1481 people have browsed it

如果是刚安装成功后,密码为空,修改密码方法为: mysqladmin -u root password '11111' 密码不为空,修改密码方法有两种: 1) mysqladmin -u root -p'111111' password '123456' 2) update mysql.user set password=PASSWORD('123456') where user='root' #


如果是刚安装成功后,密码为空,修改密码方法为:
mysqladmin -u root password '11111'


密码不为空,修改密码方法有两种:

1)
mysqladmin -u root -p'111111' password '123456'

2)
update mysql.user set password=PASSWORD('123456') where user='root'

#一定要刷新权限

flush privileges;



忘记root密码的补救方法


单实例:
killall mysqld
mysqld_safe --skip-grant-tables &  #以这种方式启动
mysql -u root -p

在my.cnf中[mysqld]添加一行
skip-grant-tables

多实例:
killall mysqld
mysqld_safe --defaults-file=/data/3306/my.cnf --skip-grant-table &
mysql -u root -p -S /data/3306/mysql.sock





修改密码:
update mysql.user set password=PASSWORD('oldboy') where user='root';
flush privileges;


改完后重启测试:
killall mysqld
单实例:/etc/init.d/mysqd restart
多实例:/data/3306/mysql restart



【文章作者】曾健生

【作者邮箱】zengjiansheng1@126.com

【作者QQ】190678908

【作者博客】blog.csdn.net/newjueqi



source:php.cn
Statement of this Website
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
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template