首页 技术 正文
技术 2022年11月11日
0 收藏 595 点赞 4,075 浏览 905 个字

1. 修改密码有三种方法:
1.1 —->用mysqladmin修改密码
格式:mysqladmin -u用户名 -p旧密码 password 新密码

例子:
# mysqladmin -uroot -p123456 password 123

只用mysqladmin的时候,会出现一个warning警告信息:
Warning: Using a password on the command line interface can be insecure.
这个没关系,是提示你,你直接在命令窗口下使用明文设置密码的时候,是不安全的,因为别人可以通过翻看你输入指令的历史记录来查看到你设置的密码
# history 可以查看到mysqladmin设置的密码,不建议使用mysqladmin设置密码

1.2 —->用set password命令
格式:mysql> set password for 用户名@localhost = password(‘新密码’);

例子:
# mysql -p
mysql> set password for root@localhost = password(‘Xl_2020?’);
mysql> flush privileges;

1.3 —->用update直接编辑mysql库中的user表来修改密码
例子:
mysql> update mysql.user set password=PASSWORD(‘password’) where user=’root’;

mysql> update mysql.user set password=PASSWORD(‘password’) where user=’root’ and host=’localhost’   # 加上主机
mysql> flush privileges;

2. 以上修改数据库密码的前提是知道当前的密码,那么如果忘记数据库的密码如何重置呢?

# vi /etc/my.cnf
在[mysqld]的段中加上一句:skip-grant-tables

# /etc/init.d/mysqld restart
# mysql
mysql>    –用上面1.2或者1.3的方法修改密码

密码修改完成后,把my.cnf的skip-grant-tables去掉,再重启数据库即可

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,077
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,552
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,400
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,176
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,813
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,894