How can I change mysql port from 0 to 3306?

前端 未结 7 2050
轻奢々
轻奢々 2021-02-19 03:27

I find it hard to establish a link between jdbc and mysql. I think one of the reasons is the mysql port. I checked the port with the statement: \"show variables like \'port\';\"

相关标签:
7条回答
  • 2021-02-19 03:39

    You can change the port number in the MySQL config file: my.cnf

    0 讨论(0)
  • 2021-02-19 03:43

    On my ubuntu install, in /etc/mysql/my.cnf theres a line that says :

    [mysqld]
    port = 3306
    <snip...>
    

    Try changing this value accordingly and restarting mysql.

    Hope it works for you.

    0 讨论(0)
  • 2021-02-19 03:52

    First of all check what SHOW VARIABLES LIKE 'skip_networking'; if it reports skip_networking = On, your mysqld is started without networking support (which leads to an value of 0 in the port system variable).

    If this is the case, you most likely have to check the init scripts for your mysqld, its most likely under /etc/init.d/mysql, search here for --skip-networking and comment out (delete) this part. After this procedure you have to restart your mysqld.

    Normaly there is no need to set the port 3306 explicitly since 3306 is the default port for mjysqld to listen on.

    0 讨论(0)
  • 2021-02-19 03:56

    allow remote connection fixed, didn't change " GLOBAL VARIABLES LIKE 'PORT';" edit my.cnf /etc/my.cnf

    [mysqld]
    user            = mysql
    basedir         = /usr
    pid-file        = /var/run/mysqld/mysqld.pid
    socket          = /var/run/mysqld/mysqld.sock
    port            = 3306
    datadir         = /var/lib/mysql
    tmpdir          = /tmp
    language        = /usr/share/mysql/English
    bind-address    = 65.55.55.2
    # your mysql server ip address should place in bind-address
    # skip-networking
    

    restart the mysql service

    0 讨论(0)
  • 2021-02-19 03:57

    You need to change this value from mysql configuration file. Steps are:

    • To go to related file: sudo nano /etc/mysql/my.cnf

    • To search for related line:(for Win, Linux) ctrl + w , (for Mac) cmd + w

    port = 0

    (look for twice for [client] and [mysqld] sections)
    
    • Replace your new value
    port            = 3306
    
    • Save and Exit
    ctrl + x , cmd + x
    y
    
    • Restart service

    sudo service mysql restart

    0 讨论(0)
  • 2021-02-19 03:59

    You need to edit your mysql config file, my.cnf in /etc/my.cnf and change the port to 3306. Then restart mysql.

    Source: http://www.cyberciti.biz/faq/change-default-mysql-port-under-linuxunix/

    Edit:

    This website might help you a bit more for your specific platform: https://wiki.archlinux.org/index.php/MySQL#Configuration

    It has a portion talking about copying over your my.cnf file:

    Copy your choice of config file:

    # cp /usr/local/mysql/support-files/my-medium.cnf /usr/local/mysql/data/my.cnf

    0 讨论(0)
提交回复
热议问题