客户端连接时报错MySQL数据库出现:Error 1045错误时,就表明输入的用户名或密码错误被拒绝访问了。

解决办法可以分为以下几步:

1.修改mysql配置文件,使得可以无密码登录mysql

sudo vim /etc/mysql/my.cnf

在[mysqld]项下添加

skip-grant-tables

2.重启mysql服务

sudo service mysql restart

3.无密码登录mysql

mysql -uroot -p

4.修改管理员密码

use mysql;

update user set password=password('123') where user='root';

flush privileges;

exit;

5.还原配置文件

6.可以使用下面的命令登录

mysql -uroot -p123

2003 - Can't connect to MySQL server on 'x.x.x.x' (10038)

mysql服务没问题:

  1. sean@sean:~$ ps -ef|grep mysqld
  2. mysql      1219      1  0 21:09 ?        00:00:01 /usr/sbin/mysqld
  3. sean      10373   9602  0 21:38 pts/7    00:00:00 grep --color=auto mysqld

并且本地的登录也能成功:

  1. sean@sean:~$ mysql -u root -h 127.0.0.1
  2. Welcome to the MySQL monitor.  Commands end with ; or \g.
  3. Your MySQL connection id is 40
  4. Server version: 5.5.47-0ubuntu0.14.04.1 (Ubuntu)
  5. Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
  6. Oracle is a registered trademark of Oracle Corporation and/or its
  7. affiliates. Other names may be trademarks of their respective
  8. owners.
  9. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  10. mysql>

但是使用外网地址却无法登录:

  1. sean@sean:~$ mysql -u root -h 192.168.137.128
  2. ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.137.128' (111)

于是修改了一下MySQL的配置文件:

  1. sean@sean:~$ sudo vi /etc/mysql/my.cnf

在bind-address= 127.0.0.1这一行前加#(注释掉这行)

  1. # Instead of skip-networking the default is now to listen only on
  2. # localhost which is more compatible and is not less secure.
  3. #bind-address           = 127.0.0.1

然后重启mysql服务:

  1. sean@sean:~$ sudo service mysql restart
  2. mysql stop/waiting
  3. mysql start/running, process 11622

ERROR 1130: mysql 1130连接错误的有效解決方法

    mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A Database changed
mysql> select host, user, password from user;
+-----------+------------------+-------------------------------------------+
| host | user | password |
+-----------+------------------+-------------------------------------------+
| localhost | root | |
| sean | root | |
| 127.0.0.1 | root | |
| ::1 | root | |
| localhost | debian-sys-maint | *0AA379AB8AFD785B32D661A07E9D5C7A24E3B186 |
+-----------+------------------+-------------------------------------------+
5 rows in set (0.00 sec) mysql> update user set host = "%" where host = "sean" and user = "root";
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) mysql> select host, user, password from user;
+-----------+------------------+-------------------------------------------+
| host | user | password |
+-----------+------------------+-------------------------------------------+
| localhost | root | |
| % | root | |
| 127.0.0.1 | root | |
| ::1 | root | |
| localhost | debian-sys-maint | *0AA379AB8AFD785B32D661A07E9D5C7A24E3B186 |
+-----------+------------------+-------------------------------------------+
5 rows in set (0.00 sec)

使用Navicat就可以成功连接至数据库了.

Ubuntu server 安装的mysql数据库忘记密码的解决方法的更多相关文章

  1. Mysql数据库忘记密码找回方法

    Mysql数据库忘记密码找回 a 停止mysql服务 /etc/init.d/mysql stop b 使用--skip-grant-tables启动mysql,忽略授权登录验证 mysqld_saf ...

  2. mysql数据库忘记密码时如何修改(一)

    方法/步骤 打开mysql.exe和mysqld.exe所在的文件夹,复制路径地址 打开cmd命令提示符,进入上一步mysql.exe所在的文件夹. 输入命令  mysqld --skip-grant ...

  3. Windows下mysql忘记密码的解决方法

    Windows下mysql忘记密码的解决方法 mysql5.0 http://www.jb51.net/article/21984.htm方法一: 1.在DOS窗口下输入 net stop mysql ...

  4. Centos下忘记mysql的root密码的解决方法

    Centos下忘记mysql的root密码的解决方法 一:(停掉正在运行的mysql) [root@NetDakVPS ~]# service mysql stop 二:使用 “--skip-gran ...

  5. Mac下新安装的MySQL无法登陆root用户解决方法

      一 设置MySQL命令行搜索路径 0.苹果->系统偏好设置->最下边点mysql 在弹出页面中 启动mysql服务 1.打开终端,输入: sudo vi ~/.bash_profile ...

  6. mysql8忘记密码的解决方法

    mysql8忘记密码的解决方法 1.管理员身份打开cmd,进入dos 2.停止mysql服务 命令:net stop mysql 3.无密码启动 命令:mysqld --console --skip- ...

  7. Windows2008系统忘记密码的解决方法

    网上转载的,忘记密码不用发愁了.   windows2008系统忘记密码的解决方法: 利用放大镜的漏洞来重设密码 首先用系统盘来引导 选择修复计算机 然后打开命令提示符:先备份放大镜,然后用CMD替换 ...

  8. MySQL数据库忘记密码怎么办?

    忘记MySQL数据库密码就进不去数据库,也就无法修改密码,解决方法如下: 1:打开cmd命令符,先关闭正在运行的数据库,输入如下命令: 2:打开mysql.exe和mysqld.exe所在的文件夹,复 ...

  9. 忘记mysql超户密码的解决方法

    本文章针对用yum安装的mariadb数据库,如果是tar包安装的mysql数据库,只是数据库命令的关闭启动方式不同而已. 方法一:[root@localhost ~]# killall -u mys ...

随机推荐

  1. iOS开发之--当遇到tableView整体上移时的解决方案

    方案一在使用了navigationController后,当界面进行跳转往返后,时而会出现tableView上移的情况,通常会自动上移64个像素,那么这种情况,我们可以关闭tableView的自动适配 ...

  2. Hadoop1.2.1 配置文件详解

    首先我们先回顾一下Hadoop的一些概念: Apache Hdoop 1.x 组成 NameNode(元数据服务器) Secondary NameNode(辅助元数据服务器) JobTracker(任 ...

  3. AsyncTask--远程图片获取与本地缓存

    对于客户端——服务器端应用,从远程获取图片算是经常要用的一个功能,而图片资源往往会消耗比较大的流量,对应用来说,如果处理不好这个问题,那会让用户很崩溃,不知不觉手机流量就用完了,等用户发现是你的应用消 ...

  4. VC启动一个新线程的三种方法

    第一种AfxBeginThread() 用AfxBeginThread()函数来创建一个新线程来执行任务,工作者线程的AfxBeginThread的原型如下: CWinThread* AfxBegin ...

  5. 【集中工作薄】 当前文件夹中所有Excel文件中 多个工作簿的第一个工作表 复制到工作簿中

    功能:当前文件夹中所有Excel文件中 多个工作簿的第一个工作表 复制到工作簿中 Sub Books2Sheets() '定义对话框变量 Dim fd As FileDialog Set fd = A ...

  6. LAMP集群项目四 安装apache、php及其插件

    rpm -qa httpd* 查看是否有apache rpm -e httpd-2.2.22.2  卸载该文件,如果不让卸载,则加参数:--nodeps 不做软件中的依赖检查 ./configure ...

  7. PHP 开发环境的搭建和使用02--整合让apache处理php

    PHP5.3.5直接下载解压即可.但是怎样才能让apache处理php呢? 1/  在apache 的conf目录下 的 httpd.conf(用于指定apache的设置)加入如下代码:   Load ...

  8. [LintCode] 第一个错误的代码版本

    /** * class VersionControl { * public: * static bool isBadVersion(int k); * } * you can use VersionC ...

  9. LeetCode 笔记系列四 Remove Nth Node From End of List

    题目:Given a linked list, remove the nth node from the end of list and return its head.For example, Gi ...

  10. 11.Curator扩展库

        Recipes组件包含了丰富的Curator应用的组件.但是这些并不是ZooKeeper Recipe的全部.大量的分布式应用已经抽象出了许许多多的的Recipe,其中有些还是可以通过Cura ...