Serverspace Black Friday
JT
October 27, 2023
Updated October 27, 2023

How to connect to a MySQL database?

Databases Linux

Introduction

Database systems are of paramount importance in the realm of enterprise operations for an array of distinctive rationales. They serve as the bedrock for the judicious storage and expeditious retrieval of data, assuring that the copious data streams generated by an enterprise are meticulously organized and readily accessible. Addressing the paramount concern of data security, databases furnish authentication and encryption capabilities that safeguard sensitive information from any unwarranted incursion. They also serve as the sentinels of data integrity, zealously upholding consistency rules, and are endowed with scalability features that can effortlessly expand to accommodate the burgeoning requirements of a growing enterprise.

Furthermore, databases provide the essential analytical underpinning for data-driven decision-making and extensive reporting, gracefully manage concurrent access by multiple stakeholders, and proffer robust mechanisms for data backup and recovery. Their role in facilitating adherence to regulatory compliance standards is pivotal, cementing them as an indispensable tool in the arsenal of contemporary enterprises.

Local & Remote connect

If you have small or medium company where server in the physical access to you, connect through the local panel on your machine. Also if you have remote access to the server via SSH, then method also fit for your purposes! For those who use SSH, at first you need connect to the server:

ssh root@94.141.98.22

Instead of root, indicate login of user in server, also change IP-address for machine to yours! After that enter the password or if you have public key on the server, just connect to them. Next we need to write command mysql and credentials for connection:

mysql -u root -p

Option -u indicate user of database, them added administrator if you haven't data, then require them from him. By -p parameter we indicate authentification via the password:

Local connect
Screenshot №1 — Local connect

Alright, we are into the DBMS! There is another one way to connect to MySQL, for that we will use two machine. At the first we have installed client of MySQL, at the second server. On the server side we need to login in the system with privileges, which allows create user, after that write:

CREATE USER 'name_user'@'ip_user'
IDENTIFIED BY 'password';

Replace template credentials for your case, ip_user mean public client IP-address which will be use for identified them on the server. If you don't now them, check it out by the command:

apt-get install curl -y && curl ifconfig.me

That line will install curl utility and check your IP-address:

check-IP
Screenshot №2 — Check IP

In my case IP-address client is 109.207.171.124, therefore after created user, list of them will be look like that:

SELECT user FROM mysql.user;
User creation
Screenshot №3 — User creation

Remind! That configuration we make on the server side! But, there is another one step for connect to remote database, we need to change config file, by the default MySQL server listen localhost. For change that open the file and change row with bind-address for 0.0.0.0:

nano /etc/mysql/mariadb.conf.d/50-server.cnf
Change configuration
Screenshot №4 — Change configuration

Maybe you will not find needed parameter in the file, that okey, just add that below. Save changes by Ctrl + O and exit by Ctrl + X, if you use nano text editor. Reboot the service by the command:

systemctl restart mysql
systemctl status mysql
check-status
Screenshot №5 — Check status

Alright MySQL server was started up, let's switch to the client side! For remote connect we need to type:

mysql -u remote -h 94.141.98.98 -p
Client command
Screenshot №6 — Client command

Enter your password into the filed below and then we can get access to the server!

Conclusion

The database systems are the linchpin of efficient data management in enterprise operations. They not only ensure the orderly storage and quick retrieval of data but also serve as bastions of data security, upholding the integrity of information while adhering to regulatory standards. Moreover, databases provide the analytical foundation for informed decision-making, enable concurrent access, and offer robust backup and recovery mechanisms.

Vote:
5 out of 5
Аverage rating : 5
Rated by: 1
33145 North Miami, FL 2520 Coral Way apt 2-135
+1 302 425-97-76
700 300
ITGLOBAL.COM CORP
700 300

You might also like...

We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.