Executing SQL Statements
Now let’s look at how the mysql program is used to execute a SQL statement on a MySQL database.
Selecting a Database to Use
Your username and password give you access to one or more specific databases. For instance, if you are using a MySQL server provided by your web host, your username will give you access only to the database that is included with your web space. Other customers have their own individual passwords.
When you are connected to MySQL, issue the show databases command to see which databases are available to you. The SHOW DATABASES command is specific to MySQL but is executed through the mysql program like all other SQL commands.
mysql> Show Databases; +--------------------+ | Database | +--------------------+ ...
Get Sams Teach Yourself MySQL now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.