Well, the error is pretty clear. You need to select the database to apply the query to.
I assume here that you are using MySQL WorkBench and that you have connected to a database using the menu item Database->Connect to Database.
In order to run SQL queries in the script window in MySQL you need to either define the database explicitly like
SELECT * FROM DataBaseName.TableName
or select the default database.
Usually you do this by double clicking on a database name in the schema navigator.
.