SQL Life

忘记Mysql登陆密码怎么办?

时间:2014/11/11 21:03:29  作者:solgle  来源:www.solgle.com  查看:643  评论:0
内容摘要:----忘记密码是常事,但是忘记Mysql密码怎么办,登陆上Linux服务器[root@solgle-srv mysql]# ps -auxWarning: bad syntax, perhaps ...
----忘记密码是常事,但是忘记Mysql密码怎么办,登陆上Linux服务器
本文出自:http://www.solgle.com/news/119.html
[root@solgle-srv mysql]# ps -aux
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0  19416  1488 ?        Ss   Oct10   0:05 /sbin/init
root         2  0.0  0.0      0     0 ?        S    Oct10   0:03 [kthreadd]
... ...
root     18095  0.2  0.0      0     0 ?        S    Oct29  53:04 [kworker/0:2]
root     46849  0.0  0.0  11392  1356 ?        S    Nov05   0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var
mysql    46950  0.1 25.7 1308104 457524 ?      Sl   Nov05  16:56 /usr/sbin/mysqld --basedir=/usr --datadir=/
 
----杀掉mysqld进程
[root@solgle-srv mysql]# kill 46950
[root@solgle-srv mysql]# kill 46950
-bash: kill: (46950) - No such process
[root@solgle-srv mysql]# 
 
---通过skip-grant-tables&进入mysql
[root@solgle-srv mysql]# /usr/bin/mysqld_safe --skip-grant-tables&
[1] 10718
[root@solgle-srv mysql]# 141112 13:45:12 mysqld_safe Logging to '/var/lib/mysql/solgle-srv.err'.
141112 13:45:12 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.20-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)
 
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
mysql> 
 
mysql> update user set password=password('12345') where user='root' ;
Query OK, 4 rows affected (0.01 sec)
Rows matched: 4  Changed: 4  Warnings: 0
 
----刷新生效,不然旧密码都能登录
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
 
mysql> 
 
 
---开启及设置防火墙
[root@solgle-srv mysql]# service iptables start
[root@solgle-srv mysql]# chkconfig iptables on   
[root@solgle-srv mysql]# 
[root@solgle-srv mysql]# iptables -IINPUT -p tcp --dport 3306 -j ACCEPT
[root@solgle-srv mysql]# service iptables restart;
iptables:将链设置为政策 ACCEPT:filter                    [确定]
iptables:清除防火墙规则:                                 [确定]
iptables:正在卸载模块:                                   [确定]
iptables:应用防火墙规则:                                 [确定]
[root@solgle-srv mysql]# 
[root@solgle-srv mysql]# iptables-save
# Generated by iptables-save v1.4.7 on Wed Nov 12 15:13:52 2014
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [7:804]
-A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT 
-A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT 
-A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT 
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT 
-A INPUT -p icmp -j ACCEPT 
-A INPUT -i lo -j ACCEPT 
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT 
-A INPUT -j REJECT --reject-with icmp-host-prohibited 
-A FORWARD -j REJECT --reject-with icmp-host-prohibited 
COMMIT
# Completed on Wed Nov 12 15:13:52 2014
 
 
标签:忘记Mysql登陆密码怎么办 

出处:solgle
网址:www.solgle.com
相关文章
    相关评论
     img1 img2 img3 img4 img5 img6 img7 img8 img9 img10
    评论者:      验证码:  点击获取验证码
       Copyright © 2013-2028 solgle.com,All rights reserved.[solgle.com] 公安机关备案号:51010802000219
    Email:solgle@solgle.com; weixin:cd1008610000 ICP:蜀ICP备14011070号-1