Of course! The USE command is how you tell MySQL which database you want to work with. Think of it like opening a specific folder before you start editing files.
Here is a practical example based on your current lab environment:
1. Check your available databases
First, you can see what databases exist:
SHOW DATABASES;
2. Select a database
To select the database named Hello_World, you run:
USE Hello_World;
Output:
Database changed
3. Verify you are inside
Once you see "Database changed," any commands you run (like creating a table or viewing data) will happen inside Hello_World. You can confirm this by looking at your MariaDB prompt, which should change from [(none)] to [Hello_World]:
MariaDB [Hello_World]> SHOW TABLES;
Key things to remember:
- The
USEstatement does not requires a semicolon at the end in some clients, but it is good practice to include it for consistency. - You can switch databases at any time. For example, to look at system settings, you can simply type
USE mysql;. - If you try to use a database that doesn't exist, you will get an error like:
ERROR 1049 (42000): Unknown database 'name'.
You've already successfully tried this in your command history—great job! Do you want to try creating a table inside the Hello_World database next?