mysql root密码的修改方法

来源:未知 责任编辑:智问网络 发表时间:2013-10-07 01:31 点击:

Method 1:
在/usr/local/mysql/bin/下:
./mysqladmin -u root password new_password
一般安装时用此方法设置。

Method 2:
在mysql状态下:
mysql>UPDATE user SET password=PASSWORD(new_password) WHERE user=root;
mysql>FLUSH PRIVILEGES;

Method 3:
mysql>SET PASSWORD FOR root=PASSWORD(new_password);

有人会问如果不知道mysql root的密码情况下,是否可以修改密码呢?答案:可以的,想知道方法请继续往下看:

只有在mysqld启动的时候加上 --skip-grant-tables就ok,

例:

[root@server]# /usr/local/mysql/bin/mysqld_safe --skip-grant-tables &

[root@server]# /usr/local/mysql/bin/mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 7
Server version: 5.0.45-log Source distribution

Type help; or h for help. Type c to clear the buffer.

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set password=password(******)where user=root;
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

杀掉mysql的进程或者重新启动mysql,然后重新登录,密码生效。

    发表评论
    请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
    用户名: 验证码:点击我更换图片
    最新评论 更多>>

    推荐热点

    • mysql-mmm
    • mysqldump命令——MySQL数据库备份还原
    • Oracle数据导入MySQL的快捷工具:MySQL Migration Toolkit
    • 简简单单储存过程——循环一个select结果集
    • MySQL数据库十大优化技巧
    • Mysql主主复制架构配置
    • Mysql安装笔记
    • MySQL Stmt预处理提高效率问题的小研究
    • Mysql的Procedure 参数为NULL问题分析
    网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
    Copyright © 2008-2015 计算机技术学习交流网. 版权所有

    豫ICP备11007008号-1