How to Open MySQL in a Linux Command Terminal



Linux


In this article, we show how to open up MySQL in a linux command terminal (shell).

So linux is fully capable of running MySQL in the shell.

Your system, first, however, must have mysql-server installed on it.

Once mysql-server is installed on the linux machine, then you can open up MySQL in the linux shell.

If you haven't installed mysql-server, then you can do so with the following code below.



Assuming you already have installed mysql-server on your linux machine, you can open up MySQL using the following code shown below.



<

Where you see username above, substitute this with the user you created the MySQL-server with. This could be the root user (if so, the code is, mysql -u root -p) or another user.

You will then be prompted to enter in the password.

This is the password for the user that you are logging into the mysql-server with. This is the password you supplied at the time of the installation of mysql-server (or if you changed the password since the installation, you supply this).

Once you do this, you now have full access to MySQL in the linux shell.

You can do all things with MySQL as normal.

In the code below, I create a database called users and then I show all databases.

Running MySQL 
on apache web server in Linux

Lastly, I exit the MySQL software with the statement, quit.

This then brings you back to the linux command terminal in the shell.

This is one way to execute MySQL code on a database on your website. It's fine but it's probably not the easiest way to do it. Many people prefer using GUI software, a popular one being phpMyAdmin. phpMyAdmin provides a visual interface so that database administrators can create MySQL databases with more ease.

Despite the fact that phpMyAdmin supplies an easier-to-work-with interface for working with MySQL databases, it wouldn't be needed for all instances. In some instances, opening up MySQL in the shell would is more convenient for basic things such as creating a new database or checking existing databases or tables. So the MySQL software still has its use within the shell.

And this is how to open MySQL in the linux shell. s


Related Resources

How to Randomly Select From or Shuffle a List in Python



HTML Comment Box is loading comments...