广告
返回顶部
首页 > 资讯 > 数据库 >Mysql无法远程连接解决方案
  • 388
分享到

Mysql无法远程连接解决方案

2024-04-02 19:04:59 388人浏览 泡泡鱼
摘要

前言 Mysql 版本:5.7.23操作系统:linux问题描述:只能通过Linux系统账号Root命令行进入数据库,无法使用JDBC,远程连接工具进入数据库。报错:ERROR 1698 (28000):

前言

Mysql 版本:5.7.23
操作系统linux
问题描述:
只能通过Linux系统账号Root命令行进入数据库,无法使用JDBC,远程连接工具进入数据库
报错:ERROR 1698 (28000): Access denied for user 'root'@'localhost'
这个问题明显就是没有开放远程连接授权,所以导致只能使用Linux的Root账号登录。

解决流程

1.找到/etc/mysql/mysql.conf.d/mysqld.cnf文件,在[mysqld]最后面加skip-grant-tables

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
# 
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# Http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# This will be passed to all mysql clients
# It has been reported that passWords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the Socket location.

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

[mysqld_safe]
socket      = /var/run/mysqld/mysqld.sock
nice        = 0

[mysqld]
#
# * Basic Settings
#
user        = mysql
pid-file    = /var/run/mysqld/mysqld.pid
socket      = /var/run/mysqld/mysqld.sock
port        = 3306
basedir     = /usr
datadir     = /var/lib/mysql
tmpdir      = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
# 加入的内容,开启跳过权限校验
skip-grant-tables
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address        = 127.0.0.1
#
# * Fine Tuning
#
key_buffer_size     = 16M
max_allowed_packet  = 16M
thread_stack        = 192K
thread_cache_size       = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover-options  = BACKUP
#max_connections        = 100
#table_open_cache       = 64
#thread_concurrency     = 10
#
# * Query Cache Configuration
#
query_cache_limit   = 1M
query_cache_size        = 16M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a perfORMance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file        = /var/log/mysql/mysql.log
#general_log             = 1
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Here you can see queries with especially long duration
#slow_query_log     = 1
#slow_query_log_file    = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
#server-id      = 1
#log_bin            = /var/log/mysql/mysql-bin.log
expire_logs_days    = 10
max_binlog_size   = 100M
#binlog_do_db       = include_database_name
#binlog_ignore_db   = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem

保存后,重启服务sudo service mysql restart.

2.无验证进入mysql数据库修改user表中root账号信息,flush privileges;

ckmike@ckmikePC:~$ mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.23-0ubuntu0.18.04.1 (Ubuntu)

Copyright (c) 2000, 2018, 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> 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> update mysql.user set authentication_string=password('账号密码') where user='root';
Query OK, 0 rows affected, 1 warning (0.03 sec)
Rows matched: 3  Changed: 0  Warnings: 1

mysql> update user set plugin="mysql_native_password";
Query OK, 1 row affected (0.00 sec)
Rows matched: 7  Changed: 1  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye

3./etc/mysql/mysql.conf.d/mysqld.cnf文件,去掉skip-grant-tables,开启校验

4.重启服务

sudo service mysql restart;

至此就搞定了,使用jdbc、非Linuxroot账号都可以登录了。
您可能感兴趣的文档:

--结束END--

本文标题: Mysql无法远程连接解决方案

本文链接: https://www.lsjlt.com/news/36547.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • Mysql无法远程连接解决方案
    前言 Mysql 版本:5.7.23操作系统:Linux问题描述:只能通过Linux系统账号Root命令行进入数据库,无法使用JDBC,远程连接工具进入数据库。报错:ERROR 1698 (28000): ...
    99+
    2022-10-18
  • windows7没法被远程连接解决方案
    windows7没法被远程连接怎么办,其实远程连接这个功能是比较少用户主动使用的功能,此功能比较鸡肋,并且对用户网络要求比较高,可是用户想要知道的话那就告诉大家有关windows7没法被远程连接解决方案,根据进入计算机属性能够进一步设定,而...
    99+
    2023-07-12
  • 远程无法连接mysql且出现错误的解决方法
    本篇内容主要讲解“远程无法连接mysql且出现错误的解决方法”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“远程无法连接mysql且出现错误的解决方法”吧!授权法...
    99+
    2022-10-18
  • 阿里云数据库无法远程连接问的解决方案
    阿里云数据库是一种高性能、高可用的云计算数据库服务,它能够提供强大的数据处理能力,满足各种复杂业务场景的需求。然而,在使用过程中,可能会遇到一些问题,如无法远程连接阿里云数据库。本文将详细介绍如何解决这个问题。 首先,我们来了解一下阿里云数...
    99+
    2023-11-16
    阿里 解决方案 数据库
  • Centos 7无法SSH远程连接及解决方法
    Centos 7无法SSH远程连接及解决方法 小土豆Linux学习随笔 —— 清听凌雪慕忆 ​ 以前运维中,服务器或者虚拟机安装完Centos 7系统,配置网络设置后即可利用SSH远程。昨夜,怪哉,不...
    99+
    2023-10-06
    ssh centos 服务器
  • MySQL8.0无法远程连接访问的解决方法
    问题:mysql  8.0 无法远程连接访问 原因:可能是mysql数据库user表中,用户的 host 字段配置是不允许当前host访问或者是访问的加密方式不对,旧版的MySQL和新版的密码加密方式不一致,但...
    99+
    2023-01-28
    MySQL8.0远程访问 MySQL远程访问
  • 宝塔安装MySQL无法远程连接【已解决】
    我是阿里云的服务器! 确保阿里云开放3306端口。宝塔开放3306端口 确保MySQL root用户(或者你要连接的用户)的权限是允许所有的人连接! 如何查看? 如果MySQL安装成功的话,在本地连...
    99+
    2023-09-12
    mysql 数据库 服务器
  • 如何解决无法远程连接mysql的问题
    这篇文章给大家分享的是有关如何解决无法远程连接mysql的问题的内容。小编觉得挺实用的,因此分享给大家做个参考。一起跟随小编过来看看吧。无法远程连接mysql的解决方法:1、登录mysql;2、执行【gra...
    99+
    2022-10-18
  • 解决无法远程连接MySQL服务的问题
    ① 设置MySQL中root用户的权限: [root@nginx-dev etc]# mysql -uroot -pRoot@123mysql> use mysql;mysql> GRANT ALL PRIVILEGES ON *.* TO...
    99+
    2023-08-30
    服务器 mysql android
  • Navicat Premiun远程连接MySQL报错10038解决方案
    远程连接MySQL失败,可能有一下原因: 小伙子/小姑凉注意一下你的ip是否输入正确了!! 网络或防火墙问题   1)、排查网络问题     使用命令:ping 192.168.1.1 查看网络请求是否超时。    ...
    99+
    2022-05-21
    Navicat Premiun 远程连接 MySQL 报错 10038
  • MYSQL不能远程连接的解决方法
    这篇文章主要介绍“MYSQL不能远程连接的解决方法”,在日常操作中,相信很多人在MYSQL不能远程连接的解决方法问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”MYSQL不能远...
    99+
    2022-10-18
  • 远程连接服务器mysql失败的解决方案
     问题描述: 在本地远程连接服务器中的数据库失败 解决方案: 1、 未开启mysql远程登录账号 (1)创建新用户时可以直接使用如下命令 create user 'your_name'@'%' identified by 'your_p...
    99+
    2023-10-25
    mysql
  • 如何解决mysql客户端无法连接远程mysql问题
    本篇内容主要讲解“如何解决mysql客户端无法连接远程mysql问题”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“如何解决mysql客户端无法连接远程mysql...
    99+
    2022-10-18
  • mysql不可以远程连接的解决方法
    这篇文章主要介绍mysql不可以远程连接的解决方法,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!mysql不可以远程连接的解决方法:1、打开命令提示符,登录mysql;2、执行【gr...
    99+
    2022-10-18
  • MySQL 1130异常,无法远程登录解决方案详解
    目录问题:一、开启远程登录权限:二、刷新MySQL权限:三、测试:问题: mysql:1130 is not allowed to connect to this MariaDB server(没有远程登录权限,注:...
    99+
    2022-05-21
    MySQL 1130错误 MySQL 1130无法远程登录
  • 电脑远程连接云服务器无法连接网络的解决方法
    1. 检查网络连接 首先,确保你的电脑本身已经成功连接到互联网。检查你的网络连接状态,确保你的电脑已经连接到一个可用的网络,并且能够正常访问其他网站。 2. 检查云服务器网络设置 如果你的电脑已经成功连接到互联网,但是无法远程连接到云服务...
    99+
    2023-10-28
    解决方法 服务器 电脑
  • Win10Xbox无法连接网络该怎么办?Xbox无法连接网络解决方案
    许多客户使用Xbox,作为win10系统内置的平台游戏和应用,广泛用于视频录制和游戏下载。可是有Win10客户体现自身在应用全过程中碰到无法连接网络的状况,这应该怎么办?下边大家就一起来看看Xbox无法连接网络的解决方案。Xbox无法连接网...
    99+
    2023-07-10
  • 连接mysql报1130.解决方案
    一、以权限用户root登录 mysql -u root -p 二、选择mysql库 mysql>use mysql; 三、查看mysql库中的user表的host值(即可进行连接访问的主机/IP名称) mysql>select "...
    99+
    2015-01-02
    连接mysql报1130.解决方案
  • windows10打印机共享无法连接解决方案
    假如windows10打印机共享出现了无法连接的难题,我们要怎么办呢,最先便是打开电脑的构想选项,随后点击网络和Internet找到共享选项,这个开启启用网络发现、开启文档和打印机共享这两个选项,最终挑选无密码设置的共享储存,这样就能处理电...
    99+
    2023-07-10
  • 无法连接win10蓝牙设备的解决方案
    我们可以利用蓝牙设备,在无网络环境下传输文件或连接蓝牙耳机欣赏音乐等。但最近,一些网民说,他们的win10计算机蓝牙不能连接怎么了?下面的小边将教你如何连接win10蓝牙设备。这种情况可能是由驱动问题引起的。以下小系列将向您展示具体的解决方...
    99+
    2023-07-10
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作