Communicate with the MySQL Server

Learn to interact with the MySQL server.

Connect the MySQL server

Now that we know that the MySQL server is running and how to stop and start it, let’s look at the command-line tool that we’ll be using to connect to the MySQL server.

In our terminal, type in the following command:

mysql -u root -p

We’ll be asked to give the password of the root user on our MySQL installation. If there’s no password on the installation, hit the “Enter” key. If our root server has a password, then we need to give it here.

Note: If the root user doesn’t have a password, we can start MySQL with the command mysql -u root

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.36-0ubuntu0.18.04.1 (Ubuntu)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> 

Get hands-on with 1400+ tech skills courses.