Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the default port of mysql from 3306 to 3360

I want to change the default port number of MySQL server presently it is 3306. I want to change it to 3360.

I have tried:

-- port=3360

But things are not working for me. Please provide query to change port not any configuration. I am using Windows 8 64 bit.

like image 962
programminglover Avatar asked Apr 25 '15 14:04

programminglover


People also ask

Is MySQL port always 3306?

Port 3306 is the default port for the classic MySQL protocol ( port ), which is used by the mysql client, MySQL Connectors, and utilities such as mysqldump and mysqlpump.

How do I stop using port 3306?

Press Ctrl + F and write 3306 to find out which Application is using PORT 3306. After this, Go to Task Manager via Search Bar or by pressing CTRL + ALT + DEL . Then Under the Background Processes, find out mysqld.exe , right-click on it and you will find an option to close it, namely " End Task ".


4 Answers

You need to edit your my.cnf file and make sure you have the port set as in the following line:

port = 3360

Then restart your MySQL service and you should be good to go. There is no query you can run to make this change because the port is not a dynamic variable (q.v. here for MySQL documentation showing a table of all system variables).

like image 107
Tim Biegeleisen Avatar answered Oct 04 '22 05:10

Tim Biegeleisen


If you're on Windows, you may find the config file my.ini it in this directory

C:\ProgramData\MySQL\MySQL Server 5.7\

You open this file in a text editor and look for this section:

# The TCP/IP Port the MySQL Server will listen on
port=3306

Then you change the number of the port, save the file. Find the service MYSQL57 under Task Manager > Services and restart it.

like image 29
Emmanuel N K Avatar answered Oct 04 '22 03:10

Emmanuel N K


On newer (for example 8.0.0) the simplest solution is (good choice for a scripted start-up for example):

mysqld --port=23306
like image 12
Gergely Bacso Avatar answered Oct 04 '22 03:10

Gergely Bacso


When server first starts the my.ini may not be created where everyone has stated. I was able to find mine in C:\Documents and Settings\All Users\Application Data\MySQL\MySQL Server 5.6

This location has the defaults for every setting.

# CLIENT SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by MySQL client applications.
# Note that only client applications shipped by MySQL are guaranteed
# to read this section. If you want your own MySQL client program to
# honor these values, you need to specify it as an option during the
# MySQL client library initialization.
#
[client]

# pipe
# socket=0.0
port=4306  !!!!!!!!!!!!!!!!!!!Change this!!!!!!!!!!!!!!!!!

[mysql]
no-beep

default-character-set=utf8
like image 3
ddavisqa Avatar answered Oct 04 '22 04:10

ddavisqa