MYSQL database how to check if database is active and on which port (Linux)

linuxMySQL

I got the server and on it is some mysql database TEST.
I tried connected on it with my root account by using DBVisualizer but I keep getting could not connect check host name and port.

I tried with root account and also with TEST user account.
Their passwords are OK.

with command

mysql> show databases;

I found my TEST database.
I do not know any other parameters how to connect to database?
I suppose either root or test can connect to it.
How to check on which port is the database or does it have to be active?

I tried with netstat and this is my response? what does it mean?

netstat -an | grep -i mysql
unix  2      [ ACC ]     STREAM     LISTENING     8596     /var/run/mysqld/mysqld.sock

Thanks

Best Answer

It seems that your mysql connection is only listening by unix sockets and now by the actual TCP.

To solve that, go to your configuration file, usually on /etc/mysql/ folder with the name my.cnf on Ubuntu(if you are using some other system should be similar).

In the configuration file you should have a section called [client].

make your server to listen on 127.0.0.1:3306 by:

[client]
port        = 3306
#socket     = /var/run/mysqld/mysqld.sock
host = 127.0.0.1

And than restart the server.

Now you should have access to the mysql shell by doing on your command line.

mysql -U TEST -h 127.0.0.1 -p db_name

Or you can use any other client you want.