[root@M ~]# vi /etc/my.cnf
[mysqld]
skip-grant-tables
[root@M ~]# service mysqld restart
Shutting down MySQL... SUCCESS!
Starting MySQL.. SUCCESS!
mysql> insert into user(user,password,host) values ('root','','localhost');
mysql> update user set Host='localhost',select_priv='y', insert_priv='y',update_priv='y',delete_priv='y',create_priv='y',drop_priv='y',reload_priv='y',shutdown_priv='y',Process_priv='y',file_priv='y',grant_priv='y',References_priv='y',index_priv='y',create_user_priv='y',show_db_priv='y',super_priv='y',create_tmp_table_priv='y',Lock_tables_priv='y',execute_priv='y',repl_slave_priv='y',repl_client_priv='y',create_view_priv='y',show_view_priv='y',create_routine_priv='y',alter_routine_priv='y',create_user_priv='y' where user='root';
Query OK, 1 row affected (0.05 sec)
Rows matched: 1 Changed: 1 Warnings: 0
[root@M ~]# grep skip /etc/my.cnf
#skip-grant-tables
skip-external-locking
#skip-networking
slave-skip-errors = all
[root@M ~]# service mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL.. SUCCESS!
[root@M ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.40-log MySQL Community Server (GPL) Copyright (c) 2000, 2014, 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.05 sec) mysql>
mysql> update user  set password=password("123") where host='localhost';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0 mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
[root@M ~]# mysql -uroot -p123
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.5.40-log MySQL Community Server (GPL) Copyright (c) 2000, 2014, 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>

mysql root 用户被删的更多相关文章

  1. mysql root用户kill connection报ERROR 1095 (HY000): You are not owner of thread N

    今日某系统mysql root用户kill connection时报ERROR 1095 (HY000): You are not owner of thread N 按说通过root用户具有supe ...

  2. 禁止、允许MySQL root用户远程访问权限

    关闭MySQL root用户远程访问权限: use mysql; update user set host = "localhost" where user = "roo ...

  3. Linux中Mysql root用户看不到mysql库问题解决方式

    第一种方式: 1.首先停止MySQL服务:service mysqld stop2.加参数启动mysql:/usr/bin/mysqld_safe --skip-grant-tables &  ...

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

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

  5. centos误删mysql root用户找回办法

    一天,我进入mysql后,查看所有用户 select host,user from mysql.user; 发现好多用户名, 太乱了,删除..... delete from user where us ...

  6. MySQL root用户忘记密码怎么办?修改密码方法:skip-grant-tables

    忘记密码怎么办? 1.以管理员身份打开cmd2.执行命令tasklist |findstr mysql ,查看正在运行的mysql进程 3.执行命令taskkill /F /PID 13644(此处进 ...

  7. 【Mysql】Mysql root用户误删了或只剩下没有任何操作权限的用户怎么办

     一.操作步骤 1.停止mysql服务:在mysql安装目录下找到mysqld.cnf:在mysqld.cnf中找到以下片段[mysqld]:另起一行加入代码:skip-grant-tables 并保 ...

  8. [mysql]root用户登录mysql,输入密码后报错:Access denied for user 'root'@'localhost'

    问题如下: wangju-G4:~$ mysql -u root -p Enter password: ERROR (): Access denied for user 'root'@'localho ...

  9. mysql root用户登录后无法查看数据库全部表

    可能是把root@localhost用户删掉了. 首先停掉mysql服务,在/etc/my.cnf中添加 skip-grant-tables,同时可以添加skip-networking选项来禁用网络功 ...

随机推荐

  1. jQuery 回调函数

    jQuery(回调函数) 此函数的作用将callback参数以函数的定义形式,在页面onload的时候进行调用.相当于$(document).ready(callback). <script t ...

  2. Delphi 6 保存窗体设置

    DSK Desktop Setting File 保存工程文件的桌面摆布情况, 下次打开时可以恢复上次保存的桌面状态 Desktop文件.保存了IDE的布局(也可能包含浏览记号,视乎IDE的设定),为 ...

  3. ECMAScript新特性【一】--Object.create

    Object.create(prototype, descriptors) :创建一个具有指定原型且可选择性地包含指定属性的对象 参数: prototype 必需.  要用作原型的对象. 可以为 nu ...

  4. 1644 免费馅饼 题解(c++)

    1644 免费馅饼(巴蜀oj上的编号) 题面:          SERKOI最新推出了一种叫做"免费馅饼"的游戏.         游戏在一个舞台上进行.舞台的宽度为W格,天幕的 ...

  5. c++ 读写Excel及数据导入SQLServer

    c++ 读写Excel及数据导入SQLServer                 C++操作Excel ,网上的资料还是比较多的,写这篇文章也是分享给初学者一些经验. 本人 觉得CSpreadShe ...

  6. ArrayList的使用和List<T>的比较

    使用非泛型集合类的限制可以通过编写一小段程序来演示,该程序利用 .NET Framework 基类库中的 ArrayList 集合类.ArrayList 是一个使用起来非常方便的集合类,无需进行修改即 ...

  7. API的文件遍历,未使用CFileFind,因为里面牵扯MFC,编个DLL好麻烦。

    // FindFileDebug.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include "FindFileDebug. ...

  8. systemctl使用

    systemctl start httpd.service 这会启动httpd服务,就我们而言,Apache HTTP服务器. 要停掉它,需要以root身份使用该命令: systemctl stop ...

  9. [转载]手工安全测试方法&修改建议

    转载自: Web安全测试(一)-手工安全测试方法&修改建议 1.XSS(Cross-Site Script)跨站脚本攻击 XSS(Cross-Site Script):跨站脚本攻击. 它指的是 ...

  10. 算法笔记_041:寻找和为定值的多个数(Java)

    目录 1 问题描述 2 解决方案 1 问题描述 输入两个整数n和sum,要求从数列1,2,3,...,n中随意取出几个数,使得它们的和等于sum,请将其中所有可能的组合列出来. 2 解决方案 上述问题 ...