MySql登陆密码忘记了 怎么办?
root密码:
连root密码忘记
没用root进修改mysql数据库user表咯
root密码:
方法一:
MySQL提供跳访问控制命令行参数通命令行命令启MySQL服务器:
safe_mysqld --skip-grant-tables&
即跳MySQL访问控制任何都控制台管理员身份进入MySQL数据库
需要注意修改完密码要MySQL服务器停掉重新启才效
方法二:
进行步骤重新设置MySQLroot密码:
1.首先确认服务器于安全状态没能够任意连接MySQL数据库
重新设置MySQLroot密码期间MySQL数据库完全于没密码保护
状态其用户任意登录修改MySQL信息采用MySQL
外端口封闭并且停止Apache及所用户进程实现服务器准安全
状态安全状态服务器Console面操作并且拔掉网线
2.修改MySQL登录设置:
# vi /etc/my.cnf
[mysqld]段加句:skip-grant-tables
例:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-name-resolve
skip-grant-tables
保存并且退vi
3.重新启mysqld
# /etc/init.d/mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
4.登录并修改MySQLroot密码
# /usr/bin/mysql
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 3 to server version: 3.23.56
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 ( ‘new-password’ ) WHERE User = ‘root’ ;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0
mysql> flush privileges ;
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye
5.MySQL登录设置修改
# vi /etc/my.cnf
刚才[mysqld]段加skip-grant-tables删除
保存并且退vi
6.重新启mysqld
# /etc/init.d/mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
windows
1.系统管理员身份登陆系统
2.打cmd—–net start 查看mysql否启启停止net stop mysql.
3.我mysql安装d:usrlocalmysql4in
4.跳权限检查启mysql.
d:usrlocalmysql4inmysqld-nt –skip-grant-tables
5.重新打cmd进d:usrlocalmysql4in:
d:usrlocalmysql4inmysqladmin -uroot flush-privileges password newpassword
d:usrlocalmysql4inmysqladmin -u root -p shutdown 句提示重新输密码
6.cmdnet start mysql
7.搞定
2MySQL4.1版本种密码错误问题解决
1 # SET PASSWORD FOR ’some_user’@’some_host’ = OLD_PASSWORD(‘newpwd’);
2 # FLUSH PRIVILEGES;
3Mysql数据库修复
myisamchk -r -q d:mysqldatalatin1*
r代表修复
q代表快速
d:mysqldatalatin1*数据库面 *代表面所文件
方法三:
忘记MYSQLroot口令通面程恢复
1. 向mysqld server 发送kill命令关掉mysqld server( kill -9),存放进程ID文件通MYSQL数据库所目录
kill `cat /mysql-data-directory/hostname.pid`
必须UNIXroot用户或者所运行SERVER同等用户才能执行操作
2. 使用`--skip-grant-tables' 参数启 mysqld
3. 使用`mysql -h hostname mysql'命令登录mysqld server 用grant命令改变口令做:`mysqladmin -h hostname -u user password 'new password''
(其实用use mysql; update user set password =password('yourpass') where user='root' 做)
4. 载入权限表: `mysqladmin -h hostname flush-privileges' 或者使用 SQL 命令`FLUSH PRIVILEGES'(重启mysqld)
四:(定要先备份)
1重新另台电脑安装相同版本MySQL
2删除忘记密码电脑MySQL安装目录datamysql全部内容(要先停止MySQL服务)
3Copy新装电脑MySQL安装目录datamysql全部内容 to 刚刚删除目录
4启MySQL服务
root用户密码空……