I've managed to get into MySQL using the command line terminal, but when I tried to enter some SQL, it said 'no database selected'
how do I select a database? my database name is: photogallery
What code do I use to select it?
You can use SQL command USE to select a particular database.
To access a specific database, type the following command at the mysql> prompt, replacing dbname with the name of the database that you want to access: Copy use dbname; Make sure you do not forget the semicolon at the end of the statement. After you access a database, you can run SQL queries, list tables, and so on.
Change or switch DATABASE in MySQL To change or switch DATABASE, run the same USE database_name query with the new database name that you wish to work on. In the example shown above, USE db3; changes the database, from db2 to db3, on which your SQL queries effect on.
Use USE
. This will enable you to select the database.
USE photogallery;
12.8.4: USE Syntax
You can also specify the database you want when connecting:
$ mysql -u user -p photogallery
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With