daz holmes daz holmes - 1 year ago 81
Linux Question

MySQL Connection Refused

i've looked up every tutorial on how to fix this and nothing worked so far,
I'm getting this error
No connection could be made because the target machine actively refused it
i'm using linux centos7 mysql version
mysql Ver 14.14 Distrib 5.6.32, for Linux (x86_64) using EditLine wrapper
blow is my.cnf
also i had to create my own my.cnf as when i installed mysql it didn't have one located i put this into etc/my.cnf it's running the cnf as it's taken mysql out of strict mode.

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.


# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....

bind-address =

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M


Answer Source

Ok, I am assuming that you have installed this on a completely different machine (as opposed to a Virtual Host on your Windows box).

You need to make sure that port 3306 is open on your DB server first and foremost. You can check this with a port checker (there are plenty of free ones online).

Then, with the user you are trying to connect with, you need to make sure that user has access from the origin IP address (i.e. the IP on your Windows machine). This can be done with the following code from the mysql prompt.

GRANT ALL PRIVILEGES ON <your db name>.* TO <your user>@<your ip> IDENTIFIED BY '<your password>';

A less secure option would be to allow all inbound IPs by using the % wildcard.

After this you need to run the following command.


That should be it.