FreeKB - mySQL / MariaDB Configure MariaDB to allow remote connections (bind)
mySQL / MariaDB - Configure MariaDB to allow remote connections (bind)

By default, after a clean install of mySQL or MariaDB, you should be able to connect to the database as root on the system that mySQL or MariaDB has been installed on. This can be confirmed with the mysql command.

mysql -u root -p

 

This should prompt you for root password.

Enter password:

 

Assuming you are able to enter a valid password, something like this should be displayed.

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 26
Server version: 10.5.10-MariaDB-log MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

 


Remote connection

To be able to connect to mySQL or MariaDB from a remote system, you will need to update the main mySQL or MariaDB configuration file (e.g. /etc/my.cnf) to have the IP address of the system. You will need to restart mySQL or MariaDB for this change to take effect.

bind-address=10.14.56.3

 

You will also need to configure a user with permission to connect to make a remote connection. The select mysql users command can be used to display a users permissions.

mysql -e "select * from mysql.user \G"

 

In this example, user john.doe has access to host %. The % character is used for remote connections.

Host: %
User: john.doe

 

By default, mySQL or MariaDB listens on port 3306. Assuming the mysql client has been installed on the remote system, the mysql command can be used to make a remote connection to mySQL or MariaDB.

mysql --host foo.example.com --port 3306 --user john.doe --password

 

Or to connect to the database named "db001".

mysql --host foo.example.com --port 3306 --user john.doe --password db001

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 690c2 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |