How to Run MySQL Client

in #utopian-io7 years ago (edited)

What Will I Learn?

  • You will learn how to Run MySQL Client which is accessed from cmd

Requirements

  • MySQL
  • You have basic about MySQL

Difficulty

  • Basic

Tutorial Contents

MySQL client used to communicate with MySQL server. MySQL client comes in many forms. It's accessed from cmd, web-based, and desktop-based apps.

XAMPP provides phpMyAdmin page as MySQL client. phpMyAdmin is a web based MySQL client. If you install MySQL separately, there is an option to install the MySQL Workbench app, this is

MySQL client in the form of desktop applications. The simplest MySQL client (and I will use throughout this book) is cmd based (command prompt). Where we type SQL commands manually to communicate with MySQL server.

If you have previously used phpMyAdmin, certainly feel very easy in managing MySQL database using the application. We just click, select the menu, and in a few minutes the database is completed without writing any SQL command.

Behind the practicality, phpMyAdmin application is less suitable for learning process. The essence of understanding MySQL is in writing SQL commands or "queries". In PHP later, this SQL command should be written in order to create a web-based database applications. The newphpMyAdmin application is suitable if we already understand most MySQL queries.

Well let's get into practice running MySQL client from cmd. The trick is similar to running a MySQL server, only this time accessed is the file \ mysql.exe bin.

Before you start, make sure the MySQL server is running, either from XAMPP Control Panel or manually from cmd. Then, reopen cmd and type the following command:


c:\xampp\mysql\bin\mysql -uroot

If the writing is correct, a "welcome" text from MariaDB will appear:

Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 10.1.25-MariaDB mariadb.org binary distribution
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

1.jpg

The command c: \xampp\mysql\bin\mysql -uroot means, I am looking for mysql.exe file that resides in the folder c:\xampp\mysql\bin\ , then log in as the root user.

To exit the MySQL client, type the command: exit .
2.jpg

The command mysql -uroot can only be used to access the XAMPP built-in MariaDB which has no password. If used for MySQL / MariaDB installed separately, will come out error messages. Why? Because the root user for MySQL / MariaDB uses a password.

Next I will try to access the separate installed MariaDB. Here's the command to login as root user into MariaDB, do not forget to change the password::

c: \ mariadb \ bin \ mysql -uroot -prahasia

3.jpg

Let's discuss the command used to log into this MySQL client with more details. Here is the basic format of MySQL login command:

mysql -h host -u user –p_password

To login to MySQL server on localhost as root user with password (For example I use password: rahasia), its command is:

c:\mariadb\bin\mysql -h localhost -u root –prahasia

Since localhost is the default value of the host, the above command may be abbreviated:

c:\mariadb\bin\mysql -u root –prahasia

If the MySQL server resides on another computer with IP address 10.12.254.14, then the command becomes:

c:\mariadb\bin\mysql -h 10.12.254.14 -u root –prahasia

In the above command, the password for the user is directly written and easy to see. To be more secure (from the person who is peering password behind you), can use alternative commands:

c:\mariadb\bin\mysql -u root –p

The cmd view pauses to wait for us to input the password:

Enter password:*****

4.jpg


May be useful



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

@suparmanyunus2, I like your contribution to open source project, so I upvote to support you.

Your contribution cannot be approved because it does not follow the Utopian Rules.

Coin Marketplace

STEEM 0.16
TRX 0.13
JST 0.027
BTC 60589.35
ETH 2628.62
USDT 1.00
SBD 2.53