• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

MySQL密码问题

mysql 搞代码 4年前 (2022-01-09) 16次浏览 已收录 0个评论

在linux下:如果 MySQL 正在运行,首先杀之: killall -TERM mysqld。 启动 MySQL :bin/safe_mysqld –skip-grant-tables 就可

1.mysqladmin -uroot -poldpassword password newpassword
2.mysql> update mysql.user set password=PASSWORD(‘新密码’) where User=’root’;
mysql> flush privileges;
mysql> quit
3.mysql -u root mysql
mysql> UPDATE user SET pas

本文来源gao!daima.com搞$代!码网

sword=PASSWORD(“new password”) WHERE user=’name’;
  mysql> FLUSH PRIVILEGES;
  mysql> QUIT
4.可以修改MYSQL文件夹中的MY.INI文件

5.使用SET PASSWORD语句,
mysql> SET PASSWORD FOR myuser@localhost = PASSWORD(‘mypasswd’);

6.使用GRANT … IDENTIFIED BY语句
mysql> GRANT USAGE ON *.* TO myuser@localhost IDENTIFIED BY ‘mypassword’;

在windows下:
打开命令行窗口,停止mysql服务:Net stop mysql
到mysql的安装路径启动mysql,在bin目录下使用mysqld-nt.exe启动,在命令行窗口执行:mysqld-nt –skip-grant-tables
然后另外打开一个命入令行窗口,执行mysql,此时无需输入密码即可进入。
>use mysql
>update user set password=password(“new_pass”) where user=”root”;
>flush privileges;
>exit
使用任务管理器,找到mysqld-nt的进程,结束进程!
在重新启动mysql-nt服务,就可以用新密码登录了。

在linux下:
如果 MySQL 正在运行,首先杀之: killall -TERM mysqld。
启动 MySQL :bin/safe_mysqld –skip-grant-tables &
就可以不需要密码就进入 MySQL 了。
然后就是
>use mysql
>update user set password=password(“new_pass”) where user=”root”;
>flush privileges;
重新杀 MySQL ,用正常方法启动 MySQL 。

1)停止windows服务中的mysql实例

2)使用–skip-grant-tables 参数启动mysql,这种模式下,无需root密码就可以登陆mysql.

mysqld-max-nt –skip-grant-tables

3)登陆mysql,,修改密码

C:\Documents and Settings\binzhang>mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.27-community-max-nt
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> use mysql;
Database changed
mysql> update user set password=password(“root”) where user=”root”;
Query OK, 1 row affected (0.07 sec)
Rows matched: 1 Changed: 1 Warnings: 0


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:MySQL密码问题
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址