Mysql is set to port 3306 but it doesn't listen on it

First of all, I am sorry for my non-native English. For a school project, I must set a WordPress with a mysql (and a phpmyAdmin but this is not the matter here) with Kubernetes, each in a different service. Both services work in their own containers.

But the problem is they must work witch each other but on different services, so I tried to configure mysql to accept remote connections to the database. I tried many things but didn’t find the solution. Mysql is set to use the port 3306 but the netstat command shows that no process is listening on port 3306.

The containers run on alpine linux (mandatory)

Here is my mariadb-server.cnf:

# # These groups are read by MariaDB server. # Use it for options that only the server (but not clients) should see  # this is read by the standalone daemon and embedded servers [server]  # this is only for the mysqld standalone daemon [mysqld] #skip-networking port=3306 bind-address=0.0.0.0  # Galera-related settings [galera] # Mandatory settings #wsrep_on=ON #wsrep_provider= #wsrep_cluster_address= #binlog_format=row #default_storage_engine=InnoDB #innodb_autoinc_lock_mode=2 # # Allow server to accept connections on all interfaces. # # # Optional setting #wsrep_slave_threads=1 #innodb_flush_log_at_trx_commit=0  # this is only for embedded server [embedded]  # This group is only read by MariaDB servers, not by MySQL. # If you use the same .cnf file for MySQL and MariaDB, # you can put MariaDB-only options here [mariadb]  # This group is only read by MariaDB-10.3 servers. # If you use the same .cnf file for MariaDB of different versions, # use this group for options that older servers don't understand [mariadb-10.3] 

My deployment and my service:

apiVersion: apps/v1 kind: Deployment metadata:   name: mysql-deployment   labels:     app: mysql-deployment spec:   selector:     matchLabels:       app: mysql   template:     metadata:       labels:         app: mysql     spec:       containers:       - name: mysql         image: mysql         imagePullPolicy: Never         ports:         - containerPort: 3306 
apiVersion: v1 kind: Service metadata:   name: mysql-service   labels:     app: mysql-service spec:   type: LoadBalancer   ports:   - name: port-mysql     port: 3306   selector:     app: mysql 

Here’s the script i run on my deployment to set the database:

mkdir -p /run/mysqld/ chown -R mysql:mysql /run/mysqld/ chown -R mysql:mysql /var/lib/mysql mysql_install_db --user=mysql --ldata=/var/lib/mysql /usr/bin/mysqld --user=mysql < mysql_init 

The last command displays this:

2020-07-13 22:29:50 0 [Note] /usr/bin/mysqld (mysqld 10.4.13-MariaDB) starting as process 74 ... 2020-07-13 22:29:50 0 [Note] InnoDB: Using Linux native AIO 2020-07-13 22:29:50 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2020-07-13 22:29:50 0 [Note] InnoDB: Uses event mutexes 2020-07-13 22:29:50 0 [Note] InnoDB: Compressed tables use zlib 1.2.11 2020-07-13 22:29:50 0 [Note] InnoDB: Number of pools: 1 2020-07-13 22:29:50 0 [Note] InnoDB: Using SSE2 crc32 instructions 2020-07-13 22:29:50 0 [Note] mysqld: O_TMPFILE is not supported on /var/tmp (disabling future attempts) 2020-07-13 22:29:50 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M 2020-07-13 22:29:50 0 [Note] InnoDB: Completed initialization of buffer pool 2020-07-13 22:29:50 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority(). 2020-07-13 22:29:50 0 [Note] InnoDB: 128 out of 128 rollback segments are active. 2020-07-13 22:29:50 0 [Note] InnoDB: Creating shared tablespace for temporary tables 2020-07-13 22:29:50 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ... 2020-07-13 22:29:50 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB. 2020-07-13 22:29:50 0 [Note] InnoDB: 10.4.13 started; log sequence number 60981; transaction id 21 2020-07-13 22:29:50 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool 2020-07-13 22:29:50 0 [Note] InnoDB: Buffer pool(s) load completed at 200713 22:29:50 2020-07-13 22:29:50 0 [Note] Plugin 'FEEDBACK' is disabled. 2020-07-13 22:29:50 0 [Note] Server socket created on IP: '0.0.0.0'. 2020-07-13 22:29:50 0 [Note] Reading of all Master_info entries succeeded 2020-07-13 22:29:50 0 [Note] Added new Master_info '' to hash table 2020-07-13 22:29:50 0 [Note] /usr/bin/mysqld: ready for connections. Version: '10.4.13-MariaDB'  socket: '/run/mysqld/mysqld.sock'  port: 3306  MariaDB Server 

But when I run the command netstat -ntlup, the output is:

Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name     tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      - 

I don’t understand why mysql says it listens to 3306 when netstat’s command shows that it’s not true.

Thanks for your help!

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.