sfxworks
By:
sfxworks

Do I need my key to login to mariadb?

May 3, 2017 346 views
MySQL MariaDB CentOS

I am trying to make an application that connects remotely to my mariadb server. I cannot connect via mysql-workbench or my app that I am making. I tried this tutorial and it did not work for me.

https://mariadb.com/kb/en/mariadb/configuring-mariadb-for-remote-client-access/

2 Answers

Hi @sfxworks

You need to open your firewall, since that's activated by default on CentOS:
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-using-firewalld-on-centos-7

If you already did that, then make sure you restarted MariaDB and then have a look at which services are listening on the interfaces:

sudo lsof -iTCP -sTCP:LISTEN -P
Firewalld is a complete firewall solution available by default on CentOS and Fedora servers. In this guide, we will cover how to set up a basic firewall for your server and show you the basics of managing the firewall with firewall-cmd, its command-line administrative...
  • 
    Complete!
    [root@centos-512mb-nyc3-01 etc]# cd
    [root@centos-512mb-nyc3-01 ~]# sudo lsof -iTCP -sTCP:LISTEN -P
    COMMAND   PID   USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
    sshd      760   root    3u  IPv4    13477      0t0  TCP *:22 (LISTEN)
    sshd      760   root    4u  IPv6    13486      0t0  TCP *:22 (LISTEN)
    master   1957   root   13u  IPv4    15076      0t0  TCP centos-512mb-nyc3-01:25 (LISTEN)
    master   1957   root   14u  IPv6    15077      0t0  TCP centos-512mb-nyc3-01:25 (LISTEN)
    python  23223   root    3u  IPv6 47958110      0t0  TCP *:843 (LISTEN)
    httpd   28106 apache    4u  IPv6 33492356      0t0  TCP *:80 (LISTEN)
    httpd   28107 apache    4u  IPv6 33492356      0t0  TCP *:80 (LISTEN)
    httpd   28108 apache    4u  IPv6 33492356      0t0  TCP *:80 (LISTEN)
    httpd   28109 apache    4u  IPv6 33492356      0t0  TCP *:80 (LISTEN)
    httpd   28110 apache    4u  IPv6 33492356      0t0  TCP *:80 (LISTEN)
    httpd   30704   root    4u  IPv6 33492356      0t0  TCP *:80 (LISTEN)
    httpd   30898 apache    4u  IPv6 33492356      0t0  TCP *:80 (LISTEN)
    httpd   32668 apache    4u  IPv6 33492356      0t0  TCP *:80 (LISTEN)
    [root@centos-512mb-nyc3-01 ~]# firewall-cmd --state
    not running
    [root@centos-512mb-nyc3-01 ~]# clear
    [root@centos-512mb-nyc3-01 ~]# firewall-cmd --state
    not running
    [root@centos-512mb-nyc3-01 ~]# sudo lsof -iTCP -sTCP:LISTEN -P
    COMMAND   PID   USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
    sshd      760   root    3u  IPv4    13477      0t0  TCP *:22 (LISTEN)
    sshd      760   root    4u  IPv6    13486      0t0  TCP *:22 (LISTEN)
    master   1957   root   13u  IPv4    15076      0t0  TCP centos-512mb-nyc3-01:25 (LISTEN)
    master   1957   root   14u  IPv6    15077      0t0  TCP centos-512mb-nyc3-01:25 (LISTEN)
    python  23223   root    3u  IPv6 47958110      0t0  TCP *:843 (LISTEN)
    httpd   28106 apache    4u  IPv6 33492356      0t0  TCP *:80 (LISTEN)
    httpd   28107 apache    4u  IPv6 33492356      0t0  TCP *:80 (LISTEN)
    httpd   28108 apache    4u  IPv6 33492356      0t0  TCP *:80 (LISTEN)
    httpd   28109 apache    4u  IPv6 33492356      0t0  TCP *:80 (LISTEN)
    httpd   28110 apache    4u  IPv6 33492356      0t0  TCP *:80 (LISTEN)
    httpd   30704   root    4u  IPv6 33492356      0t0  TCP *:80 (LISTEN)
    httpd   30898 apache    4u  IPv6 33492356      0t0  TCP *:80 (LISTEN)
    httpd   32668 apache    4u  IPv6 33492356      0t0  TCP *:80 (LISTEN)
    [root@centos-512mb-nyc3-01 ~]#
    
    

    It says that my firewall isn't running my default (centos 7 x64) but mariadb isn't listening on a port. How do I get it to listen?

    • @sfxworks
      Correct, MariaDB isn't listening. My guess would be that MariaDB is crashing because it's running out of RAM. You can check by showing the last 30 lines of it's error log:

      sudo tail -30 /var/log/mysql/error.log
      

      Or check if it's even running:

      sudo systemctl status mysqld
      
  • [deleted]
  • It says that my firewall isn't running by default (centos 7 x64) but mariadb isn't listening on a port. How do I get it to listen?

    • @sfxworks
      Did you remove (or comment out) both
      skip-networking and bind-address = 127.0.0.1 ?

      • @sfxworks
        Run the following command to list which configuration files to look in:

        sudo $(which mysqld) --verbose --help | grep -A 1 "Default options"
        

        Remember to restart MariaDB after changing configuration files.

Have another answer? Share your knowledge.