关闭正在运行的 MySQL :

[root@www.woai.it ~]# service mysql stop

运行

[root@www.woai.it ~]# mysqld_safe --skip-grant-tables &

为了安全可以这样禁止远程连接:

[root@www.woai.it ~]# mysqld_safe --skip-grant-tables --skip-networking &

使用mysql连接server:

[root@www.woai.it ~]# mysql -p

更改密码:

mysql> update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';

*特别提醒注意的一点是,新版的mysql数据库下的user表中已经没有Password字段了

而是将加密后的用户密码存储于authentication_string字段

mysql> flush privileges;
mysql> quit;

修改完毕。重启

[root@localhost ~]# service mysql restart

然后mysql就可以连接了

也可以使用alter user :

mysql> alter user 'root'@'localhost' identified by '';

这样也可以:

mysql> set password for 'root'@'localhost'=password('');

重点给大家介绍下mysql 5.7 root密码修改

MySQL管理者密码设置或修改:

依据官方说明5.6以后版本,第一次启动时会在root目录下生产一个随机密码,文件名.mysql_secret。

[root@bright ~]# cat /root/.mysql_secret
# Password set for user 'root@localhost' at -- ::
:Jj+FTiqvyrF
[root@bright ~]# cd /usr/local/mysql/bin/
[root@bright bin]# ./mysqladmin -u root -h localhost password '' -p

Enter password: #此行输入.mysql_secret里第二行内容

mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.

官方的方式,笔者无论是否使用--skip-grant-tables启动mysql都测试失败,亲们可以测试:

shell>mysql -uroot -p'password' #password即.mysql_secret里的密码
mysql>SET PASSWORD = PASSWORD('newpasswd');

旧版本,安装后ROOT无密码,按如下操作:

方法一:

shell>service mysqld stop #停止mysql服务
shell>mysqld_safe --skip-grant-tables & #以不启用grant-tables模式启动mysql
shell>mysql -uroot -p #输入命令回车进入,出现输入密码提示直接回车。
mysql>use mysql;
mysql>update user set password=PASSWORD("")where user="root"; #更改密码为 newpassord
mysql>flush privileges; #更新权限
mysql>quit #退出

方法二:

shell>service mysqld stop #停止mysql服务
shell>mysqld_safe --skip-grant-tables & #以不启用grant-tables模式启动mysql
shell>mysql -uroot -p #输入命令回车进入,出现输入密码提示直接回车。
mysql > set password for root@localhost = password('mysqlroot');

方法三:

shell>/path/mysqladmin -u UserName -h Host password 'new_password' -p

mysql 5.7修改密码的更多相关文章

  1. MySql数据库安装&修改密码&开启远程连接图解

    相关工具下载地址: mysql5.6 链接:http://pan.baidu.com/s/1o8ybn4I密码:aim1 SQLyog-12.0.8 链接:http://pan.baidu.com/s ...

  2. MYSQL 5.7 修改密码、登录问题

    mysql5.7 关于密码问题 报错: ERROR 1862 (HY000): Your password has expired. To log in you must change it usin ...

  3. mysql client--笔记-修改密码-登录-查看数据库-创建数据库

    1 登录 mysql client 打开 mysql client -输入密码 123 回车 2 show database; ---显示数据库 3 切换数据库:use mysql 4 describ ...

  4. 无法给MySQL root用户修改密码的解决方法

    本人编译安装完MySQL数据库,想给root用户修改密码,结果无法修改,并且报错,报错大概信息如下: mysqladmin: connect to server at 'localhost' fail ...

  5. MYSQL 5.7修改密码,登录问题

    mysql5.7 关于密码问题 报错: ERROR 1862 (HY000): Your password has expired. To log in you must change it usin ...

  6. mysql查看和修改密码策略

    8.X版本: #查看密码策略 show variables like '%validate_password.policy%'; show variables like '%validate_pass ...

  7. Mysql关闭和修改密码

    数据库的关闭方法: 1.优雅的关闭数据库的方法:mysqladmin -uroot -p123456 shutdown 2.脚本关闭:/etc/init.d/mysqld stop 3.使用kill信 ...

  8. MYSQL 5.6修改密码

    忘记了超级用户root密码的时候怎么办呢? 1. 修改配置文件跳过密码 (1)编辑mysql主配置文件my.cnf # vim /etc/my.cnf 在[mysqld] 字段下添加参数 skip-g ...

  9. mysql三种修改密码的方式

    [root@MySQL ~]# mysqladmin -uroot -proot -S /data/3307/mysql.sock password '123'; 其中-p是现在的密码,passwor ...

随机推荐

  1. 几个功能强大的系统源码(机票分销、机票预订、OA、手机充值、wifi营销、网络超市、体检平台)

    1.机票分销.机票预订系统源码 2.OA系统源码 3.手机在线充值系统源码 4.wifi营销系统源码 5.网络超市系统源码 6.在线体检平台系统源码 7.违章查询与缴费系统源码 需要的同学请联系QQ: ...

  2. SSH面试题收藏

    Hibernate工作原理及为什么要用? 原理: 1. 读取并解析配置文件2. 读取并解析映射信息,创建SessionFactory3. 打开Sesssion4. 创建事务Transation5. 持 ...

  3. 使用vs2010创建MFC C++ Ribbon程序

    Your First MFC C++ Ribbon Application with Visual Studio 2010 Earlier this month, I put together my ...

  4. MFC绘制图片闪烁详解

    用MFC如何高效地绘图             显示图形如何避免闪烁,如何提高显示效率是问得比较多的问题.     而且多数人认为MFC的绘图函数效率很低,总是想寻求其它的解决方案.     MFC的 ...

  5. URL重写 urlrouting

    在global文件中添加以下的代码 <%@ Import Namespace="System.Web.Routing" %> <script RunAt=&quo ...

  6. TcpListener的异步调用内存泄漏---最近测试结果,没有泄露

    我后来加大了client的连接/断开的次数(500,1000),Server端的连接被释放了. 这说明: 1. 此代码是 可以正常工作的. 2.TcpListener/TcpListener的asyn ...

  7. 生成highcharts报表时对数据没有用= eval('([' + seriesArray+ '])')处理生成数组,而是简单的拼成字符串,结果导致大量的场景出现

    <script type="text/javascript"> //异步初始周达成率趋势图信息 function goFinishQuery() { var yearN ...

  8. jfinal和httl结合

    一导入jar包 二配置web.xml文件 三配置httl.properties文件 此时会出现如下问题: 解决办法: 加入 javassist-3.15.0-GA.jar包 再运行会有如下警告 解决办 ...

  9. 数组的sizeof

    数组的sizeof值等于数组所占用的内存字节数,如:  char a1[] = "abc";  int a2[3];  sizeof( a1 ); // 结果为4,字符 末尾还存在 ...

  10. 当想mysql某插入有某字段设置了unique且和之前相同时,会报错,并停止运行