Не открывается порт 3306 MySQL
Поставил на VirtualBox Ubuntu server 16.04 и сервер MySQL. В сети этот комп под отдельным IP (10.0.0.4), работает через мост.
В начале не смог подключиться через MySQL Workbench, но пинг до сервера есть, начал копать в части портов. На серверe открыт только один порт, а 3306 в стутсе CLOSED
После изучения мануалов, прописал в iptables порт 3306 для подключения
$ sudo iptables -A INPUT -s 10.0.0.2/28 -p tcp --drop 3306 -j ACCEPT $ sudo iptables -A OUTPUT -s 10.0.0.2/28 -p tcp --drop 3306 -j ACCEPT
Через iptables-save сохранить не получилось, после перезагрузки все записи исчезали. Пришось установить iptables-persistent.
sudo netfilter-persistent save
все сохранилось и, после перезагрузки, все осталось в таблице
НО! Порт все еще закрыт.
Что не так, где еще копать мануал? HELP PLEASE!
Лучшие ответы ( 1 )
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
Ответы с готовыми решениями:
3306 порт
помогите не могу открыть доступ к бд mysql 3306 порту
Что занимает порт 3306
Подскажите,пожалуйста,как узнать,что занимает порт 3306. До загрузки новой версии MySQL у меня была.
Как открыть порт 3306
Дорогие друзья! Помогите Бога ради! Пытаюсь зарегистрироваться в онлайновой информационной.
Ошибка подключения МаСкуля на 3306 порт
Доброго времени суток! Сколько себя помню — каждый раз новые ошибки при установке выдает, сейчас он.
56 / 93 / 10
Регистрация: 20.03.2017
Сообщений: 550
Какой мост? Ты юзаешь сервер в виртуалке и раздаёшь это в интернет или локальная операционка не видит порт?
Регистрация: 16.02.2014
Сообщений: 47
Мост (bridge) — настройка сетевого интерфейса в VirtualBox.
Да, у меня сервер на виртуалке, и в локальной сети виден как отдельная машина. С пингом проблем нет, с подключением через SSH — тоже все норм.
Комп 10.0.0.2 (Ubuntu) не видит порт 3306 на 10.0.0.4 (Ubuntu server). Да и на самом 10.0.0.4 порт закрыт.
56 / 93 / 10
Регистрация: 20.03.2017
Сообщений: 550
Humster13, Надо конфиги мускула править чтобы он порт открыл наружу.
889 / 201 / 54
Регистрация: 06.11.2015
Сообщений: 2,113
Записей в блоге: 2
Humster13, делали это? Для MySQL remote access нужно проделать.
Регистрация: 16.02.2014
Сообщений: 47
Скажем так, большинство у меня проделано, есть вопрос по файлу конфигурации my.cnf, он у меня просто пустой.
В IPTABLES порт 3306 у меня открыт, но после команды
$ nmap -p 3306 10.0.0.4
показывает, что закрыт.
56 / 93 / 10
Регистрация: 20.03.2017
Сообщений: 550
Humster13, mysql-common ставь
Регистрация: 16.02.2014
Сообщений: 47
Он у меня стоит
![]()
![]()
12935 / 7340 / 785
Регистрация: 09.09.2009
Сообщений: 28,711

Сообщение было отмечено Humster13 как решение
Решение
в убунте, установлено по дефолту, никакие порты открывать не нужно, все правила файервола сброшены, а дефолтное действие по всем цепям (включая и input) — accept
в 16.04 мускул уже 5.7.х, и файл my.cnf в папке /etc/mysql действительно пустой
в подпапке /etc/mysql/mysql.conf.d должен быть файл mysqld.cnf. в нем — конфигурация сервера
именно в ней нужно настраивать работу сервера в сети (а не только на локалхосте)
unixforum.org
Как в mysql открыть порт 3306 для доступа извне? (желательно привязка по ip )
Обсуждение настройки и работы сервисов, резервирования, сетевых настроек и вопросов безопасности ОС.
Модератор: SLEDopit
6 сообщений • Страница 1 из 1
vladtopalov87 Сообщения: 57
Как в mysql открыть порт 3306 для доступа извне?
Как в mysql открыть порт 3306 для доступа извне?
желательно для определенный ip
спасибо
Спасибо сказали:
keir Сообщения: 317 ОС: linux Контактная информация:
Re: Как в mysql открыть порт 3306 для доступа извне?
Сообщение keir » 25.02.2007 12:39
Возможно имеется ввиду то, что по-умолчанию MySQL смотрит только на 127.0.0.1
За это отвечает строчка bind-address в файле my.cnf.
Закоменнтировать ее, а для отдельных ip уже рулить iptables-ом.
Как открыть 3306 порт, debian 10?
5.Перезапустил сервис mysql
6.При попытке удаленного подключения к базе, выдаёт «unknown error», через telnet 3306 — нет ответа от сервера.
spoiler
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp — anywhere anywhere tcp dpt:telnet
ACCEPT all — anywhere anywhere ctstate RELATED,ESTABLISHED
ACCEPT all — anywhere anywhere
INPUT_direct all — anywhere anywhere
INPUT_ZONES_SOURCE all — anywhere anywhere
INPUT_ZONES all — anywhere anywhere
ACCEPT tcp — anywhere anywhere tcp dpt:mysql
ACCEPT tcp — anywhere anywhere tcp dpt:http
Chain FORWARD (policy ACCEPT)
target prot opt source destination
ACCEPT all — anywhere anywhere ctstate RELATED,ESTABLISHED
ACCEPT all — anywhere anywhere
FORWARD_direct all — anywhere anywhere
FORWARD_IN_ZONES_SOURCE all — anywhere anywhere
FORWARD_IN_ZONES all — anywhere anywhere
FORWARD_OUT_ZONES_SOURCE all — anywhere anywhere
FORWARD_OUT_ZONES all — anywhere anywhere
DROP all — anywhere anywhere ctstate INVALID
REJECT all — anywhere anywhere reject-with icmp-host-prohibited
ufw-before-logging-forward all — anywhere anywhere
ufw-before-forward all — anywhere anywhere
ufw-after-forward all — anywhere anywhere
ufw-after-logging-forward all — anywhere anywhere
ufw-reject-forward all — anywhere anywhere
ufw-track-forward all — anywhere anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
OUTPUT_direct all — anywhere anywhere
ACCEPT tcp — anywhere anywhere tcp dpt:mysql
Chain INPUT_direct (1 references)
target prot opt source destination
Chain INPUT_ZONES_SOURCE (1 references)
target prot opt source destination
Chain INPUT_ZONES (1 references)
target prot opt source destination
IN_public all — anywhere anywhere [goto]
Chain FORWARD_direct (1 references)
target prot opt source destination
Chain FORWARD_IN_ZONES_SOURCE (1 references)
target prot opt source destination
Chain FORWARD_IN_ZONES (1 references)
target prot opt source destination
FWDI_public all — anywhere anywhere [goto]
Chain FORWARD_OUT_ZONES_SOURCE (1 references)
target prot opt source destination
Chain FORWARD_OUT_ZONES (1 references)
target prot opt source destination
FWDO_public all — anywhere anywhere [goto]
Chain OUTPUT_direct (1 references)
target prot opt source destination
Chain IN_public (1 references)
target prot opt source destination
IN_public_log all — anywhere anywhere
IN_public_deny all — anywhere anywhere
IN_public_allow all — anywhere anywhere
ACCEPT icmp — anywhere anywhere
Chain IN_public_log (1 references)
target prot opt source destination
Chain IN_public_deny (1 references)
target prot opt source destination
Chain IN_public_allow (1 references)
target prot opt source destination
ACCEPT tcp — anywhere anywhere tcp dpt:mysql ctstate NEW,UNTRACKED
Chain FWDI_public (1 references)
target prot opt source destination
FWDI_public_log all — anywhere anywhere
FWDI_public_deny all — anywhere anywhere
FWDI_public_allow all — anywhere anywhere
ACCEPT icmp — anywhere anywhere
Chain FWDI_public_log (1 references)
target prot opt source destination
Chain FWDI_public_deny (1 references)
target prot opt source destination
Chain FWDI_public_allow (1 references)
target prot opt source destination
Chain FWDO_public (1 references)
target prot opt source destination
FWDO_public_log all — anywhere anywhere
FWDO_public_deny all — anywhere anywhere
FWDO_public_allow all — anywhere anywhere
Chain FWDO_public_log (1 references)
target prot opt source destination
Chain FWDO_public_deny (1 references)
target prot opt source destination
Chain FWDO_public_allow (1 references)
target prot opt source destination
Chain ufw-before-logging-input (0 references)
target prot opt source destination
Chain ufw-before-logging-output (0 references)
target prot opt source destination
Chain ufw-before-logging-forward (1 references)
target prot opt source destination
Chain ufw-before-input (0 references)
target prot opt source destination
Chain ufw-before-output (0 references)
target prot opt source destination
Chain ufw-before-forward (1 references)
target prot opt source destination
Chain ufw-after-input (0 references)
target prot opt source destination
Chain ufw-after-output (0 references)
target prot opt source destination
Chain ufw-after-forward (1 references)
target prot opt source destination
Chain ufw-after-logging-input (0 references)
target prot opt source destination
Chain ufw-after-logging-output (0 references)
target prot opt source destination
Chain ufw-after-logging-forward (1 references)
target prot opt source destination
Chain ufw-reject-input (0 references)
target prot opt source destination
Chain ufw-reject-output (0 references)
target prot opt source destination
Chain ufw-reject-forward (1 references)
target prot opt source destination
Chain ufw-track-input (0 references)
target prot opt source destination
Chain ufw-track-output (0 references)
target prot opt source destination
Chain ufw-track-forward (1 references)
target prot opt source destination
- Вопрос задан более трёх лет назад
- 3652 просмотра
how to open port 3306

I’m trying to allow remote traffic to my mysql server. I changed my bind address in my mysqld.cnf to 0.0.0.0 , and ran sudo ufw allow 3306/tcp but I don’t think my port 3306 is allowing traffic. I’m trying to access the mysql server to store dev, staging and production.
425 1 1 gold badge 3 3 silver badges 15 15 bronze badges
asked Jun 19, 2018 at 3:23
19 1 1 gold badge 1 1 silver badge 3 3 bronze badges
running it on amazon ec2 instance should be good. ill add a picture.
Jun 19, 2018 at 3:28
Did you restart the mysql service after changing the configuration? How did you check whether it is listening?
Jun 19, 2018 at 3:44
i did. and I ran netstat -l
Jun 19, 2018 at 4:01
Check if you not have —skip-networking option when mysql daemon starts. How to check: ps -ef | grep mysql and check used options. What you got, when run ss -tnpl | grep 3306 ?
Jun 19, 2018 at 6:39
ps -ef | grep mysql returns 7290 7273 0 14:02 pts/0 00:00:00 grep —color=auto mysql ss -tnpl | grep 3306 doesn’t return anything
Jun 19, 2018 at 14:04
1 Answer 1
Do this test from different sites in your infrastructure.
Install nmap like so,
sudo apt-get install nmap
and then try to scan the database server like so:
From localhost/same machine do
sudo nmap -sS 127.0.0.1
From the same network/other machine close by do (e.G.)
sudo nmap -sS 192.168.X.X
From the Internet do (e.G.)
sudo nmap -sS 80.34.X.X
If the first and second test go well, you have a problem with your router. This problem is then not Ubuntu-related anymore, but a problem with the router you use to connect to the internet.
If the first test fails, your port is completly closed and you have to work on your mysql conf again.
If the first succeeds and the second one fails, recheck that mysql really listens to 3306. Do a
sudo netstat -tlpn
Check that 0.0.0.0 is the source ip for port 3306/tcp. If that is the case you will have to recheck the settings with ufw. Disable the ufw for testing, to see if it makes a difference.