Site icon TestingDocs.com

Working with MySQL Command Line

Working with MySQL Command Line

In this tutorial, we will learn basic steps involved working with the MySQL command line. The most basic way to work with MySQL is to connect to the database from the command prompt. You need to connect to a database to create tables, view data, etc. Let’s see how to connect to MySQL and run a sample SQL query. This is very important because it is very much like the way your programs will interact with the database.

Connect to MySQL

On Windows, choose Run from the Start menu, type “cmd” and press the Enter key.

To Run mysql.exe, type

/> mysql -u root -p 

Enter your password for the user.

Note that you need to add the MySQL executable bin directory path to the environment variables.

 

Use a database

MySQL database might have several databases on the same relational database system. To view all the databases use the below command.

mysql> show databases;

 

To connect to a particular database, type the use command

mysql> use sakila;

To view all the tables in the sakila database type the following command.

mysql> show tables;

 

 

MySQL Tutorials

MySQL Tutorials on this website:

https://www.testingdocs.com/mysql-tutorials-for-beginners/

 

Exit mobile version