Chinaunix首页 | 论坛 | 博客
  • 博客访问: 265008
  • 博文数量: 82
  • 博客积分: 2477
  • 博客等级: 大尉
  • 技术积分: 725
  • 用 户 组: 普通用户
  • 注册时间: 2009-06-06 23:24
文章分类

全部博文(82)

文章存档

2013年(1)

2012年(3)

2011年(15)

2010年(36)

2009年(27)

分类: Mysql/postgreSQL

2009-06-15 15:35:47

 1)不用密码登录
  [root@test1 local]# mysql
  ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)
  显示错误,说明密码已经修改。

修改方法:
  

Unix&Linux:
1.用root或者运行mysqld的用户登录系统;
2.利用kill命令结束掉mysqld的进程;
3.使用--skip-grant-tables参数启动MySQL Server
shell>;mysqld_safe --skip-grant-tables &(写全路径)
4.为root@localhost设置新密码
shell>;mysqladmin -u root flush-privileges password "newpassword",或直接进入mysql表中修改Password

如:

>;use mysql
>;update user set password=password("new_pass"  where user="root";
>;flush privileges;

5.重启MySQL Server

Windows:
1.用系统管理员登陆系统。
2.停止MySQL的服务。
3.进入命令窗口,然后进入MySQL的安装目录,比如我的安装目录是c:\mysql,进入C:\mysql\bin
4.跳过权限检查启动MySQL,
c:\mysql\bin>;mysqld-nt --skip-grant-tables
5.重新打开一个窗口,进入c:\mysql\bin目录,设置root的新密码
c:\mysql\bin>;mysqladmin -u root flush-privileges password "newpassword"
c:\mysql\bin>;mysqladmin -u root -p shutdown
将newpassword替换为你要用的root的密码,第二个命令会提示你输入新密码,重复第一个命令输入的密码。
6.停止MySQL Server,用正常模式启动Mysql
7.你可以用新的密码链接到Mysql了。

2)用修改后的密码登录
  [root@test1 local]# mysql -u root -p
  Enter password: (输入修改后的密码123456)
  Welcome to the MySQL monitor. Commands end with ; or \g.
  Your MySQL connection id is 4 to server version: 4.0.16-standard
  Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  mysql>
  成功!
  这是通过mysqladmin命令修改口令,也可通过修改库来更改口令。

阅读(642) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~