Access MySQL Shell
Now, let's access the MySQL shell to perform some basic operations.
To access the MySQL shell, use the following command:
sudo mysql -u root
This command uses sudo
to run with administrative privileges, which is often required for system-level operations. The mysql
command is used to access the MySQL shell, and the -u root
flag specifies that you're connecting as the root
user.
There's no need to provide a password in this case because the MySQL installation on LabEx VM is configured to allow the root
user to log in without a password. This is common in development environments but should not be done in production systems.
If successful, you'll see a welcome message and the MySQL prompt:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 52
Server version: 10.6.18-MariaDB-0ubuntu0.22.04.1 Ubuntu 22.04
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
You're now in the MySQL shell, where you can execute SQL commands.
The MariaDB [(none)]>
prompt indicates that you're connected to MariaDB (a fork of MySQL) and not currently using any specific database.
It's important to note that you're seeing MariaDB instead of MySQL. Don't worry - this won't affect your ability to complete this lab or learn MySQL commands. Here's why:
- MariaDB is a fork of MySQL, created by the original developers of MySQL. It's designed to be a drop-in replacement for MySQL, meaning it's fully compatible with MySQL syntax and operations.
- MariaDB was created to ensure that a truly open-source version of MySQL would always be available. It maintains high compatibility with MySQL while also offering some unique features and improvements.
- For the purposes of this lab and most basic to intermediate MySQL operations, you can treat MariaDB exactly as you would MySQL. All the commands we'll use in this lab work identically in both MariaDB and MySQL.
- MariaDB is often considered more lightweight and faster than MySQL, which makes it an excellent choice for learning environments like this lab. You might notice quicker response times, which can make your learning experience smoother.
- Many Linux distributions, including some versions of Ubuntu, now use MariaDB as their default MySQL-compatible database system due to its open-source nature and performance benefits.
So, when you see "MariaDB" in the prompt or output, just remember that for the purposes of this lab, you can think of it as MySQL. All the skills you learn here will be directly applicable to both MariaDB and MySQL in real-world scenarios.