title: how to change mysql/mariadb 10.xx default port?
body: <p>To be precise I need to change mysql/mariadb 10.xx default port to port number 15501.</p>
  
  <p>Through Internet I found that it could be changed from <code>/etc/mysql/my.cnf</code> containing a line <code>port=3306</code>, But in my cnf file there is no such line.</p>
  
  <p>My <code>my.cnf</code> contents: </p>
  
  <pre><code># The MariaDB configuration file
   #
   # The MariaDB/MySQL tools read configuration files in the following order:
   # 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults,
   # 2. "/etc/mysql/conf.d/*.cnf" to set global options.
   # 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
   # 4. "~/.my.cnf" to set user-specific options.
   #
   # If the same option is defined multiple times, the last one will apply.
   #
   # One can use all long options that the program supports.
   # Run program with --help to get a list of available options and with
   # --print-defaults to see which it would actually understand and use.
  
   #
   # This group is read both both by the client and the server
   # use it for options that affect everything
   #
   [client-server]
  
   # Import all .cnf files from configuration directory
   !includedir /etc/mysql/conf.d/
   !includedir /etc/mysql/mariadb.conf.d/
  </code></pre>
  
  <p>Don't know why But If I try <code>mysql -uroot -p -P[ANY_PORT IS ACCEPTED example 1829]</code> It connects to mariadb with any port number.</p>
  
  <pre><code>netstat -a | grep mysql
  tcp        0      0 localhost:mysql         0.0.0.0:*               LISTEN     
  unix  2      [ ACC ]     STREAM     LISTENING     17787    /var/run/mysqld  /mysqld.sock
  
  mysql --version
  mysql  Ver 15.1 Distrib 10.1.23-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
  </code></pre>
  
  <p>I'm using debian 9</p>
  
  <p>I would really appreciate if you tell me how to make mysql/mariadb listen to port 15501 number only.</p>