mysql学习之-密码管理(默认密码,修改密码,解决忘记密码)
发表于:2024-10-17 作者:千家信息网编辑
千家信息网最后更新 2024年10月17日,1. mysql安装后默认没有密码,初始化安装后默认密码登录,需要马上修改root密码。[root@mysql ~]# cat /root/.mysql_secret --查看root账号密码# Th
千家信息网最后更新 2024年10月17日mysql学习之-密码管理(默认密码,修改密码,解决忘记密码)1. mysql安装后默认没有密码,初始化安装后默认密码登录,需要马上修改root密码。
[root@mysql ~]# cat /root/.mysql_secret --查看root账号密码
# The random password set for the root user at Tue Dec 13 18:59:06 2016 (local time): 7MhtyX3aZEl9OUf8
[root@mysql ~]# mysql -uroot -p -- 登录mysql
Enter password: --(此处复制粘贴 7MhtyX3aZEl9OUf8)
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.25
Copyright (c) 2000, 2015, 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> 表示一切顺利成功。
2. 修改密码
mysql> SET PASSWORD = PASSWORD('123456'); --设置密码为123456
[root@mysql etc]# mysql -uroot -p123456 --修改密码后,登录
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 39
Server version: 5.6.25 MySQL Community Server (GPL)
mysql> --登录成功
3. 忘记mysql数据库root的密码后,如何修改密码。
[root@mysql etc]# service mysql stop --停止mysql进程
Shutting down MySQL.... SUCCESS!
[root@mysql etc]# mysqld_safe --skip-grant-tables& --启动mysql时不启动grant-tables,授权表。执行后出现下面画面,另起一个新会话。
[1] 3574
[root@mysql etc]# 161215 06:13:53 mysqld_safe Logging to '/var/lib/mysql/mysql.err'.
161215 06:13:53 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
[root@mysql ~]# ps -ef|grep mysql --查看mysql进程是否起来
root 3467 3440 0 05:29 pts/2 00:00:00 mysql -uandy -px xx
root 3574 2845 0 06:13 pts/0 00:00:00 /bin/sh /usr/bin/mysqld_safe --skip-grant-tables
mysql 3677 3574 2 06:13 pts/0 00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-
mysql> UPDATE user SET password=PASSWORD('cccccc') WHERE user='root'; --更改root密码
Query OK, 4 rows affected (0.04 sec)
Rows matched: 4 Changed: 4 Warnings: 0
mysql> FLUSH PRIVILEGES; --权限更新
Query OK, 0 rows affected (0.00 sec)
[root@mysql ~]# mysql -uroot -p123456 --使用旧密码登录,发现不行,说明密码已经更新
Warning: Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@mysql ~]# mysql -uroot -pcccccc --新密码登录成功
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
mysql>
[root@mysql ~]# cat /root/.mysql_secret --查看root账号密码
# The random password set for the root user at Tue Dec 13 18:59:06 2016 (local time): 7MhtyX3aZEl9OUf8
[root@mysql ~]# mysql -uroot -p -- 登录mysql
Enter password: --(此处复制粘贴 7MhtyX3aZEl9OUf8)
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.25
Copyright (c) 2000, 2015, 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> 表示一切顺利成功。
2. 修改密码
mysql> SET PASSWORD = PASSWORD('123456'); --设置密码为123456
[root@mysql etc]# mysql -uroot -p123456 --修改密码后,登录
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 39
Server version: 5.6.25 MySQL Community Server (GPL)
mysql> --登录成功
3. 忘记mysql数据库root的密码后,如何修改密码。
[root@mysql etc]# service mysql stop --停止mysql进程
Shutting down MySQL.... SUCCESS!
[root@mysql etc]# mysqld_safe --skip-grant-tables& --启动mysql时不启动grant-tables,授权表。执行后出现下面画面,另起一个新会话。
[1] 3574
[root@mysql etc]# 161215 06:13:53 mysqld_safe Logging to '/var/lib/mysql/mysql.err'.
161215 06:13:53 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
[root@mysql ~]# ps -ef|grep mysql --查看mysql进程是否起来
root 3467 3440 0 05:29 pts/2 00:00:00 mysql -uandy -px xx
root 3574 2845 0 06:13 pts/0 00:00:00 /bin/sh /usr/bin/mysqld_safe --skip-grant-tables
mysql 3677 3574 2 06:13 pts/0 00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-
mysql> UPDATE user SET password=PASSWORD('cccccc') WHERE user='root'; --更改root密码
Query OK, 4 rows affected (0.04 sec)
Rows matched: 4 Changed: 4 Warnings: 0
mysql> FLUSH PRIVILEGES; --权限更新
Query OK, 0 rows affected (0.00 sec)
[root@mysql ~]# mysql -uroot -p123456 --使用旧密码登录,发现不行,说明密码已经更新
Warning: Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@mysql ~]# mysql -uroot -pcccccc --新密码登录成功
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
mysql>
密码
登录
成功
进程
更新
不行
数据
数据库
权限
画面
账号
马上
新会
新密
习之
管理
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
市场监管局网络安全宣传
30软件开发性格内向 转行
ipv6 认证服务器
山丘全球网络安全吗
世界十大网络安全空间搜索引擎
企业网络安全防御的意义
陈凯歌搜索软件开发
二次软件开发税务
我们的服务器你来吗翻译
服务器没有显示器
思元270互联网领先科技
战地1服务器名
免费开源软件开发
服务器并发多大速率
与数据库交互的技术
分布式数据库可靠性
软件开发代码同步处理系统
地理空间数据库课程
戴尔服务器显卡接口
2路超融合服务器价格
快餐软件开发
当涂租房软件开发
上传数据库到服务器
服务器没有显示器
账号权限不足暂无法登陆服务器
xbox国行连不上服务器
飞机场管理系统信息数据库设计
8511研究所软件开发
希牧互联网科技有限公司股票
软件开发跟设计有关系吗