shardingsphere icon indicating copy to clipboard operation
shardingsphere copied to clipboard

Mysql Client cannot connect to sharding-proxy using address 'localhost'

Open harvies opened this issue 7 years ago • 2 comments

Bug Report

For English only, other languages will not accept.

Before report a bug, make sure you have:

Please pay attention on issues you submitted, because we maybe need more details. If no response more than 7 days and we cannot reproduce it on current information, we will close it.

Please answer these questions before submitting your issue. Thanks!

Which version of ShardingSphere did you use?

4.0.0-RC3-SNAPSHOT

Which project did you use? Sharding-JDBC or Sharding-Proxy?

Sharding-Proxy

Expected behavior

Actual behavior

Reason analyze (If you can)

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

Example codes for reproduce this issue (such as a github link).

image

image

image

image image image

Mysql Workbench log 21:59:03 [ERR][ GRTDispatcher]: exception in grt execute_task, continuing: Exception: Access denied for user 'root'@'localhost' (using password: YES) 21:59:03 [ERR][ GRTDispatcher]: worker: task 'execute sql queries' has failed with error:.Access denied for user 'root'@'localhost' (using password: YES) 21:59:07 [ERR][ GRTDispatcher]: exception in grt execute_task, continuing: Exception: Access denied for user 'root'@'localhost' (using password: YES) 21:59:07 [ERR][ GRTDispatcher]: worker: task 'execute sql queries' has failed with error:.Access denied for user 'root'@'localhost' (using password: YES) 21:59:07 [ERR][ WQE backend]: Got an exception during connection: Access denied for user 'root'@'localhost' (using password: YES) 21:59:07 [ERR][SQL Editor Form]: SQL editor could not be connected: Access denied for user 'root'@'localhost' (using password: YES) 21:59:07 [ERR][SQL Editor Form]: Your connection attempt failed for user 'root' to the MySQL server at 127.0.0.1:3307: Access denied for user 'root'@'localhost' (using password: YES)

Please: 1 Check that MySQL is running on address 127.0.0.1 2 Check that MySQL is reachable on port 3307 (note: 3306 is the default, but this can be changed) 3 Check the user root has rights to connect to 127.0.0.1 from your address (MySQL rights define what clients can connect to the server and from which machines) 4 Make sure you are both providing a password if needed and using the correct password for 127.0.0.1 connecting from the host address you're connecting from

harvies avatar Sep 15 '19 14:09 harvies

You can also use Navicat

geomonlin avatar Sep 17 '19 03:09 geomonlin

Sharding-Proxy only support TCP/IP communication for now.

MySQL client treat 'localhost' via UNIX Domain Socket while treat '127.0.0.1' via TCP/IP. This explains why you can't use localhost to connect Sharding-Proxy.

To resolve this problem you can:

  1. Set protocol=tcp in my.cnf to enforce connecting by TCP/IP. OR
  2. You can still use localhost if your MysQL client is running on Windows, because there's no UNIX socket in Windows, the address will be tranform to 127.0.0.1 automatically.

tuohai666 avatar Oct 11 '19 05:10 tuohai666