- how to change port number in MySQL Server 5.6 on windows( Not in XAMPP inbuilt mysql)
- 2 Answers 2
- Как проверить, на каком порту работает MySQL и может ли он быть подключен?
- 13 ответов:
- mysql server port number
- 9 Answers 9
- How to test which port MySQL is running on and whether it can be connected to?
- 13 Answers 13
- Узнать порт в MySQL, на котором она работает
how to change port number in MySQL Server 5.6 on windows( Not in XAMPP inbuilt mysql)
I stopped the MySQL Service in Windows from TaskManager Option.
And then, I opend and Choosed the port number in «my-default.ini». like following (C:\Program Files\MySQL\MySQL Server 5.6\my-default.ini)
[mysqld]
port = 33062
Then I stated the service ‘MySql’ from the ‘TaskManager’.
I checked the port number from ‘mysql command’ prompt. but port number is not changed to 33062. Instead of that default port number is there in the ‘my.ini’ file. Please show the way to change it.
2 Answers 2
Steps to change the port number for MySQL Server 5.7 :
- Stop the MySQL service from service.msc (To open service.msc go to run command and then type service.msc )
- Go to the location C:\ProgramData\MySQL\MySQL Server 5.7 (ProgramData is a hidden folder. So you need to enable the hidden items from Folder Options).
- In the MySQL Server 5.7 folder you will find my.ini file.
- Open my.ini file and search for port .
- Give your desired port number (like port=3632).
- Save and exit my.ini file.
- Then stat the service from the service.msc .
Follow the following simple steps
Rerun the installer by going to start > MySQL > MySQL Community Installer https://i.stack.imgur.com/s78DN.png
Click on Reconfigure next to MySQL Server
Click and Next
Now change the port numbers to maybe 3309
Click Next change the password, test it and that ends it
Как проверить, на каком порту работает MySQL и может ли он быть подключен?
Я установил MySQL и даже вошел туда как пользователь.
но когда я пытаюсь подключить так:
Не работает. Не уверен, что оба должны работать, но по крайней мере один из них должен 🙂
Как я могу убедиться, что порт действительно 3306? Есть ли команда linux, чтобы увидеть это как-то? Кроме того, есть ли более правильный способ попробовать его через url?
13 ответов:
найти слушателя на порту, сделайте следующее:
вы должны увидеть строку, которая выглядит так, если MySQL действительно прослушивает этот порт.
порт 3306 является портом MySql по умолчанию.
для подключения вам просто нужно использовать любой клиент, который вам нужен, например, базовый клиент mysql.
база данных пользователей mysql-h localhost-u
или url-адрес, который интерпретируется вашим кодом библиотеки.
grep port /etc/mysql/my.cnf (по крайней мере, в debian/ubuntu работает )
in /etc / mysql / my.КНФ, чтобы увидеть возможные ограничения
он покажет список что-то вроде ниже:
использовать в качестве корня для всех деталей. Элемент -t опция ограничивает выход TCP-соединениями, -l для прослушивания портов, -p содержит имя программы и -n показывает числовую версию порта вместо именованной версии.
таким образом, вы можете увидеть имя процесса и порт.
оба URL-адреса неверны-должно быть
Я думал, что это само собой разумеется, но для подключения к базе данных с Java требуется драйвер JDBC. Вам понадобится драйвер MySQL JDBC.
может быть, можно подключить с использованием сокетов по протоколу TCP/ИС. Проверьте MySQL docs.
Я попытался telnet в MySQL ( telnet ip 3306 ), но это не работает:
Я думаю, что это то, что вы имели в виду.
попробуйте использовать только -e ( —execute ) параметр:
заменить root по вашему «логину » и»паролю»
более простой подход для некоторых : Если вы просто хотите проверить, если MySQL находится на определенном порте, вы можете использовать следующую команду в терминале. Проверено на mac. 3306 это порт по умолчанию.
mysql —host=127.0.0.1 —port=3306
Если вы успешно войти в терминал оболочки MySQL, вы хорошо! Это выход, который я получаю при успешном входе в систему.
3306-порт по умолчанию для mysql. Проверьте это с помощью:
это должно дать такой результат:
tcp 0 0 127.0.0.1:3306 0.0.0.0: * слушайте
ошибка 1045( 28000): доступ запрещен для пользователя ‘root’@’localhost’ (используя пароль: нет)
но это сработало так:
на mac os X есть два варианта. netstat или lsof
используя netstat не будет показывать процесс на Mac OS X. Поэтому с помощью netstat вы можете искать только по порту.
Используя lsof покажет имя процесса.
Я сделал следующее, Когда я столкнулся с конфликтами портов (контейнеры docker):
netstat -aln | grep 3306
выходы: tcp46 0 0 *.3306 *.* LISTEN
sudo lsof -i -P | grep -i «LISTEN» | grep -i 3306
выходы: mysqld 60608 _mysql 31u IPv6 0x2ebc4b8d88d9ec6b 0t0 TCP *:3306 (LISTEN)
Я согласен с решением @bortunac. мой.conf является специфичным для mysql, в то время как netstat предоставит вам все порты прослушивания.
возможно, используйте оба, один для подтверждения того, какой порт установлен для mysql, а другой для проверки того, что система прослушивает через этот порт.
мой клиент использует CentOS 6.6 и я нашел мой.файл conf под /etc/, поэтому я использовал:
grep port /etc/my.conf (CentOS 6.6)
если вы находитесь в системе, где netstat недоступно (например, RHEL 7 и более поздние версии Debian) вы можете использовать ss , как показано ниже:
и вы получите что-то вроде следующего вывода:
четвертый столбец Local Address:Port . Так что в этом случае Mysql прослушивает порт 3306, по умолчанию.
mysql server port number
I’ve just made a database on mysql on my server. I want to connect to this via my website using php. This is the contents of my connections file:
I know what the username/passwords are, and I know the IP address of the server. What I’m just wondering is how do I know which port to use?
9 Answers 9
If your MySQL server runs on default settings, you don’t need to specify that.
Default MySQL port is 3306.
[updated to show mysql_error() usage]
For windows, If you want to know the port number of your local host on which Mysql is running you can use this query on MySQL Command line client —
It will give you the port number on which MySQL is running.
check this out dude
if you want to have your port as a variable, you can write php like this:
If you specify ‘localhost’ the client libs default to using the filesystem system socket on a Unix system — trying the mysql_default_socket value from php.ini (if set) then the my.cnf value.
If you connect using a different tool, try issuing the command «show variables like ‘%socket%'»
If you want to use a network port (which is a wee bit slower) then try specifying 127.0.0.1 or a physical interface asociated with the machine.
default port of mysql is 3306
default pot of sql server is 1433
This is a PDO-only visualization, as the mysql_* library is deprecated.
Note that this OP Question appeared not to be about port numbers afterall. If you are using the default port of 3306 always, then consider removing it from the uri, that is, remove the port=$port; part.
If you often change ports, consider the above port usage for more maintainability having changes made to the $port variable.
Some likely errors returned from above:
In the below error, we are at least getting closer, after changing our connect information:
After further changes, we are really close now, but not quite:
How to test which port MySQL is running on and whether it can be connected to?
I have installed MySQL and even logged in there as a user.
But when I try to connect like this:
Neither works. Not sure if both are supposed to work, but at least one of them should 🙂
How can I make sure that the port is indeed 3306? Is there a linux command to see it somehow? Also, is there a more correct way to try it via a url?
13 Answers 13
To find a listener on a port, do this:
You should see a line that looks like this if mysql is indeed listening on that port.
Port 3306 is MySql’s default port.
To connect, you just have to use whatever client you require, such as the basic mysql client.
mysql -h localhost -u user database
Or a url that is interpreted by your library code.
Using Mysql client:
grep port /etc/mysql/my.cnf ( at least in debian/ubuntu works )
in /etc/mysql/my.cnf to see possible restrictions
It will show the list something like below:
Use as root for all details. The -t option limits the output to TCP connections, -l for listening ports, -p lists the program name and -n shows the numeric version of the port instead of a named version.
In this way you can see the process name and the port.
Try only using -e ( —execute ) option:
Replace root by your «username» and «password»
Both URLs are incorrect — should be
I thought it went without saying, but connecting to a database with Java requires a JDBC driver. You’ll need the MySQL JDBC driver.
Maybe you can connect using a socket over TCP/IP. Check out the MySQL docs.
I tried to telnet into MySQL ( telnet ip 3306 ), but it doesn’t work:
I think this is what you had in mind.
A simpler approach for some : If you just want to check if MySQL is on a certain port, you can use the following command in terminal. Tested on mac. 3306 is the default port.
mysql —host=127.0.0.1 —port=3306
If you successfully log in to the MySQL shell terminal, you’re good! This is the output that I get on a successful login.
3306 is default port for mysql. Check it with:
it should give this result:
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
For me, @joseluisq’s answer yielded:
ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO)
But it worked this way:
On a mac os X, there are two options. netstat or lsof
Using netstat will not show the process on Mac OS X. so using netstat you can only search by port.
Using lsof will show the process name.
I did the following as I was encountering port conflicts (docker containers):
netstat -aln | grep 3306
Outputs: tcp46 0 0 *.3306 *.* LISTEN
sudo lsof -i -P | grep -i «LISTEN» | grep -i 3306
Outputs: mysqld 60608 _mysql 31u IPv6 0x2ebc4b8d88d9ec6b 0t0 TCP *:3306 (LISTEN)
Узнать порт в MySQL, на котором она работает
Узнать порт, назначеный MySQL для работы можно через консоль.
1. Запускаем системный терминал.
«Пуск» — «Найти программы и файлы«, в поле ввода набираем «cmd«, нажимаем «Enter«.
2. Теперь необходимо войти в MySQL.
Если при установке MySQL были указаны переменные Path, то можно сразу переходить к п.3 в противном случае нужно сначала переместиться в папку, где лежит исполняемый файл базы данных.
По умолчанию MySQL устанавливается в «C:\Program Files\MySQL» Вводим в окне:
cd C:\Program Files\MySQL\MySQL Server 5.7\bin |
Где «MySQL Server 5.7» — папка с текущей версией БД, а «bin»— папка с исполняемым файлом
3.Теперь выполняем вход в БД:
mysql.exe -uUSER -pPASSWORD |
Где «USER» — имя пользователя, а «PASSWORD»— пароль
4. Отлично, мы попали в консоль управления MySql.
Теперь вводим команду
show variables like ‘port’; |
MySql отобразит порт, на котором она работает.