远程连接Mysql数据库问题(ERROR 2003 (HY000))

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群版 2核4GB 100GB
推荐场景:
搭建个人博客
云数据库 RDS MySQL,高可用版 2核4GB 50GB
简介: <div style="color:rgb(77,77,77)"> <div> <div><span style="font-size:14px">问题代码代码</span></div> <ol start="1"><li><span style="font-size:14px">ERROR 2003 (HY000): Can't connect to MySQL server on
问题代码代码
  1. ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.0.19' (111)  

      这个 原因就是Mysql数据库的默认配置文件my.cnf(linux下)中的bind-address默认为127.0.0.1,所以就算你创建了可以 remote访问的用户,你也不能使用mysql -h命令进行访问,若访问就会出现上出问题,因为此时Mysql只接受localhost,所以需要把bind-address屏蔽掉。

     my.cnf一般在/etc/mysql下面,如果不在使用locate my.cnf查找,修改前的my.cnf配置文件为:

 

修改前的my.cnf配置文件代码
  1. #  
  2. # Instead of skip-networking the default is now to listen only on  
  3. # localhost which is more compatible and is not less secure.  
  4. bind-address           = 127.0.0.1  

     我们需要做的就是屏蔽这个bind-address代码,屏蔽后代码为:

 

屏蔽后my.cnf配置文件代码
  1. #  
  2. # Instead of skip-networking the default is now to listen only on  
  3. # localhost which is more compatible and is not less secure.  
  4. #bind-address           = 127.0.0.1  

     现在你就可以用mysql -h命令进行你想做的操作了,如登录系统:

 

登陆数据库代码
mysql -h 192.168.0.19 -u root -p 

 ERROR 2003 (HY000): Can't connect to MySQL server on "host" (111)


默认情况下Mysql只允许本地登录,所以需要修改配置文件将地址绑定给注释掉:
vim /etc/mysql/my.cnf

# 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  
注释掉这一行就可以远程登录了


相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
26天前
|
SQL 监控 关系型数据库
|
2月前
|
网络协议 关系型数据库 MySQL
mysql8.0远程连接权限设置
mysql8.0远程连接权限设置
96 0
|
2月前
|
关系型数据库 MySQL
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file
65 0
|
2月前
|
SQL 关系型数据库 MySQL
SQL Error (2013): Lost connection to MySQL server at 'waiting for initial communication packet', sys...
SQL Error (2013): Lost connection to MySQL server at 'waiting for initial communication packet', sys...
|
2月前
|
关系型数据库 MySQL 数据库连接
解决 mysql8.0 ERROR 1045 (28000): Access denied for user ‘ODBC‘@‘localhost‘ (using password: NO)用户访问拒绝
解决 mysql8.0 ERROR 1045 (28000): Access denied for user ‘ODBC‘@‘localhost‘ (using password: NO)用户访问拒绝
312 52
解决 mysql8.0 ERROR 1045 (28000): Access denied for user ‘ODBC‘@‘localhost‘ (using password: NO)用户访问拒绝
|
18天前
|
SQL 监控 关系型数据库
|
3天前
|
SQL 存储 关系型数据库
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server
|
3天前
|
SQL 关系型数据库 MySQL
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
|
9天前
|
关系型数据库 MySQL Linux
Linux系统中Mysql5.7建立远程连接
Linux系统中Mysql5.7建立远程连接
9 0
|
2月前
|
关系型数据库 MySQL 数据库
MySQL 启动 登录报错Job for mysqld.service failed because the control process exited with error code. See
MySQL 启动 登录报错Job for mysqld.service failed because the control process exited with error code. See