Mysql数据库管理员密码管理
2012-12-11 13:08
330 查看
Mysql数据库管理员密码管理 Mysql数据在维护中经常需要修改管理员密码,在多次的修改中自己也可能忘记。另外在岗位交接中也可能忘了交接数据库的密码。在这种情况下,掌握在不知道或忘了mysql的root密码的情况下修改mysql数据库的密码就变得很有必要。 不多废话,说正事: 上述情况Mysql数据库root密码修改有两种方法: 1、 改配置文件: (1)模拟错误,修改管理员密码: [root@localhost ~]# mysqladmin -uroot password "123123" [root@localhost ~]# mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) (2)修改mysql的配置文件:/etc/my.cnf [root@localhost ~]# vi /etc/my.cnf [mysqld] #在配置文件中找到mysqld模块添加 skip-grant-tables #该项必须在mysqld模块内,保存推出 (3)重启mysql并修改密码: [root@localhost ~]# service mysqld restart [root@localhost ~]# mysql #登录mysql,不需要其他 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.0.77-log Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> mysql> use mysql; #使用mysql数据库 Database changed mysql> update user set password=password("123") where user="root"; #修改root密码,注意password必须这么写,123为密码是自己定的。 Query OK, 3 rows affected (0.00 sec) Rows matched: 3 Changed: 3 Warnings: 0 mysql> flush privileges; #刷新权限 Query OK, 0 rows affected (0.00 sec) mysql> exit #退出 Bye (4)取消跳过验证模式: [root@localhost ~]# vi /etc/my.cnf [mysqld] #skip-grant-tables #这里可以注释掉、也可以直接删除 [root@localhost ~]# service mysqld restart #重启服务 (5)登录验证: [root@localhost ~]# mysql -uroot -p123 #使用root和123密码登录数据库 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.0.77-log Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> #登录成功,很爽! 2、 使用命令: (1) 停止服务,以跳过验证的模式启动mysql数据库: [root@localhost ~]# service mysqld stop 停止 MySQL: [确定] [root@localhost ~]# mysqld_safe --skip-grant-tables & #跳过用户名验证模式启动 [1] 3465 #此PID号需要记住、改完密码后需要杀死它 (2) 修改密码: [root@localhost ~]# mysql #登录mysql,不需要其他 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.0.77-log Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> mysql> use mysql; #使用mysql数据库 Database changed mysql> update user set password=password("12345") where user="root"; #修改root密码,注意password必须这么写,12345为密码是自己定的。 Query OK, 3 rows affected (0.00 sec) Rows matched: 3 Changed: 3 Warnings: 0 mysql> flush privileges; #刷新权限 Query OK, 0 rows affected (0.00 sec) mysql> exit #退出 Bye (3) 终止mysql的safe模式、正常启动mysql: [root@localhost ~]# kill -9 3465 #杀死skip模式的mysql进程 [root@localhost ~]# killall mysqld #如果没有杀干净,使用改命令杀死所有的mysqld程序,不然mysqld启动不了 [root@localhost ~]# service mysqld start (4) 验证: [root@localhost ~]# mysql #验证没有用户名及密码的登录 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) [root@localhost ~]# mysql -uroot -p12345 #新密码 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.0.77-log Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql>
相关文章推荐
- Mysql数据库理论基础之十 ---- 用户和权限管理、管理员密码重置
- MOSS 2007管理中心如何管理员修改密码
- zabbix管理:zabbix3.0监控--修改管理员(Admin)密码
- MOSS 2007管理中心如何管理员修改密码
- 重置SEP管理控制台管理员密码
- 【XAMPP】mysql数据库忘记管理员root密码
- mysql数据库忘记管理员密码的解决方法
- Linux命令:MySQL系列之十--MySQL用户和权限管理,mysql管理员密码重置
- MysqL数据库密码的管理
- 6.(Mysql数据管理相关)连接MYSQL,修改密码,增加新用户,数据库相关命令,表操作相关命令,数据相关命令,数据库sql导入和导出,备份数据库,查看不到mysql数据库的解决办法
- ubuntu 超级管理员修改Mysql数据库密码
- MySQL数据库登录密码管理
- 如何重置MySQL数据库管理员(root)密码
- N点主机管理系统密码解密代码程序
- WINDOWS SERVER 2003本地管理员、目录服务还原模式管理员、域管理员密码的破解汇总
- 忘记mysql数据库root用户密码的解决办法
- 忘记Jenkins管理员密码的解决办法
- 您配置文件中的设置 (空密码的 root) 与 MySQL 默认管理员账户对应...的解决办法
- 恢复Windows2000/XP 管理员密码
- 忘记Jenkins管理员密码的解决办法