Introduction
In this project, you will learn how to reverse print a Linux terminal command using SQL statements in the MySQL client. This project is designed to help you understand the basics of SQL and how to use it to perform simple operations on text data.
👀 Preview

🎯 Tasks
In this project, you will learn:
- How to access the MySQL database without a password using the
sudocommand - How to write an SQL statement to reverse the
catcommand - How to save the SQL statement to a file
- How to run the SQL script in the MySQL client
🏆 Achievements
After completing this project, you will be able to:
- Understand how to use SQL statements to manipulate text data
- Learn how to save and execute SQL scripts in the MySQL client
- Gain experience in using the MySQL client and performing basic database operations
Access MySQL Without a Password
In this step, you will learn how to access the MySQL database using the sudo command without any password.
- Open a terminal on your Linux system.
- Start the MySQL service by running the following command:
sudo service mysql start
- Access the MySQL client by running the following command:
sudo mysql
This will allow you to access the MySQL database without a password.
Reverse Print the ‘Cat’ Command
In this step, you will learn how to write an SQL statement to reverse print the cat command in the Linux terminal.
In the MySQL client, run the following SQL statement:
SELECT REVERSE('cat');This will reverse the string
'cat'and display the output'tac'.In the MySQL client, run the following command to save the SQL statement to the file:
SELECT REVERSE('cat');This will create the
reverseCat.sqlfile in the/home/labex/projectdirectory and save the SQL statement to it.
Run the SQL Script
In this step, you will learn how to run the reverseCat.sql script in the MySQL client.
In the MySQL client, run the following command to execute the script:
SOURCE /home/labex/project/reverseCat.sql;This will execute the SQL statement in the
reverseCat.sqlfile and display the output'tac'.
Congratulations! You have completed the project. You should see the following output:
MariaDB [(none)]> SOURCE /home/labex/project/reverseCat.sql;
+----------------+
| REVERSE('cat') |
+----------------+
| tac |
+----------------+
1 row in set (0.000 sec)
Summary
Congratulations! You have completed this project. You can practice more labs in LabEx to improve your skills.



