Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6920003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:05:35+00:00 2026-05-27T10:05:35+00:00

When I am at the office, MySQL runs on a specific server which is

  • 0

When I am at the office, MySQL runs on a specific server which is called “mysqldev”. In my /etc/hosts file I have set “mysqldev” to match the IP of this server. So far, so good. However, when I am out of the office using my laptop, I want to use my local MySQL database, as I clone specific databases there and have no internet to connect to the office database. I do not want to change my scripts, but rather my laptop configuration. So on my laptop I have set in /etc/hosts:

127.0.0.1 localhost mysqldev

However, for some reason this does not work as expected. If I log in to MySQL using the server at localhost, all good. But when I try to log in on the mysqldev server (same IP as localhost), I get the error:

Warning: mysqli::mysqli() [mysqli.mysqli]: [2002] Connection refused (trying to connect via tcp://mysqldev:3306)

(this is using PHP, but using the command line it is the same error)

The users that are set up on the system have specific permission to log in on this server:

CREATE USER 'test'@'mysqldev' IDENTIFIED BY '123';

GRANT ALL PRIVILEGES ON testdb.* TO 'test'@'mysqldev';

I have also turned off the firewall to test, and it does not make a difference. What could it be?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:05:36+00:00Added an answer on May 27, 2026 at 10:05 am

    The MySQL client library tries to guess how to connect to your database. When you give localhost as the hostname, it assumes, that you’re using a local socket (search your computer for a file named mysql.sock, probably under /var/lib/mysql or /usr/local/mysql/.

    However, when you use anything else, like an ip address, a different hostname, or, in your case, mysqldev, it tries to connect to the host via tcp. From the error message, it seems as if your local mysql server is not listening on the tcp port 3306 (the mysql default)

    Check, if your my.cnf (probably /etc/my.cnf or /etc/mysql/my.cnf) allows the use of tcp. If you find a line like

    skip-networking
    

    comment it out:

    #skip-networking
    

    and restart the server. Then try again to connect.


    To find out, where your socket is, connect through localhost and issue the following command:

    mysql> show global variables like '%socket%';
    +---------------+-----------------------------+
    | Variable_name | Value                       |
    +---------------+-----------------------------+
    | socket        | /var/run/mysqld/mysqld.sock |
    +---------------+-----------------------------+
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a local intranet application which runs off a basic WAMP server in
I have a mysql query which is being to find the stock items in
HI All, We have a .Net 2.0 application which has a MySQL backend. We
I have the following tables in MySQL server: Companies: - UID (unique) - NAME
I have a WPF application in which I use entity framework with mysql connector/net
I am developing a web application using php and mysql. This application runs on
I know that Open Office Database uses a java database backend. Does anyone have
I have a CSV export script (enrdata_arch.php) which calls information from an existing database
In one of my MySQL tables, I have following columns: Skills varchar(80) Industry varchar(40)
I'm running a server at my office to process some files and report the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.