How to change mysql default port from 3306 to 3360

I want to change the default port number for the MySQL server at present - it's 3306. I want to change it to 3360.

I tried:

-- port=3360 

But for me everything does not work. Please provide a port change request, not any configuration. I am using the 64-bit version of Windows 8.

+17
source share
9 answers

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

 port = 3360 

Then restart the MySQL service and you should be good to go. There is no query that you can execute to make this change because port not a dynamic variable (qv is here for the MySQL documentation , which shows a table of all system variables).

+20
source

If you are on Windows, you can find the my.ini configuration file in this directory

 C:\ProgramData\MySQL\MySQL Server 5.7\ 

You open this file in a text editor and see this section:

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

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

+8
source

Go to the installed mysql path and find the bin folder, open my.ini and find 3306 after this change 3306 - 3360

+2
source

In fact, you can simply start the service using /mysqld --PORT 1234 , this will make mysql work on the specified port without changing the cnf / ini file.

I just thought cnf was not working. It was sewn in ... so I just use the cmd line as a shortcut and it works!

+1
source

The best way to do this is to back up the required database and reconfigure the server.

Backup

The mysqldump command is used to create text dumps of databases managed by MySQL. These dumps are just files with all the SQL commands needed to recreate the database from scratch. The process is quick and easy.

If you want to back up one database, you simply dump and send the output to a file, for example:

 mysqldump database_name > database_name.sql 

You can back up several databases at the same time:

 mysqldump --databases database_one database_two > two_databases.sql 

In the above code, database_one is the name of the first backup of the database, and database_two is the name of the second.

It is also easy to back up all databases on the server:

 mysqldump --all-databases > all_databases.sql 

After performing the backup, uninstall mysql and reinstall it. After reinstalling with the desired port number.

Backup recovery

Since dump files are only SQL commands, you can restore the database backup by telling mysql to run the commands in it and put the data in the appropriate database.

 mysql database_name < database_name.sql 

In the above code, the database name is the name of the database you want to restore, and database_name.sql is the name of the backup file to be restored.

If you are trying to restore one database from a dump of all databases, you should tell mysql as follows:

 mysql --one-database database_name < all_databases.sql 
+1
source

When you first start the server, 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 default values ​​for each 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 
+1
source

On Windows 8.1 x64 bit os, I am currently using the MySQL version:

 Server version: 5.7.11-log MySQL Community Server (GPL) 

To change the MySQL port number, go to the installation directory, my installation directory:

 C:\Program Files\MySQL\MySQL Server 5.7 

open the configuration file my-default.ini in any text editor.

find the line in the configuration file.

 # port = ..... 

replace it with:

 port=<my_new_port_number> 

how I myself changed to:

 port=15800 

To apply the changes, be sure to immediately restart MySQL Server or your OS .

Hope this helps a lot.

0
source

The following are the steps to change the port:

 1.Open-> XAMPP Control Panel 2.Click right side showing Configuration 3.After that there are four option below select Service & Port Setting 4.Then Service Setting is open you can change port of any server 
0
source

On newer ones (for example, 8.0.0) the simplest solution (for example, a good choice to run according to the script):

 mysqld --port=23306 
0
source

Source: https://habr.com/ru/post/985945/


All Articles