MySQL List Databases

MySQL List Databases

To list the databases in a MySQL server, you can use the SHOW DATABASES command. This command will display a list of all the databases on the MySQL server.

To list the databases in a MySQL server, follow these steps:

  1. Connect to the MySQL server using the mysql utility. You can use the mysql utility to connect to the MySQL server as the root user or another user with the appropriate privileges. For example:
ref‮t re‬o:lautturi.com
mysql -u root -p

Enter the password for the user account when prompted.

  1. Use the SHOW DATABASES command to list the databases on the MySQL server. You can use the following syntax to list the databases:
mysql> SHOW DATABASES;

This will display a list of all the databases on the MySQL server. The list will include the names of the databases and their types (e.g., MyISAM, InnoDB, etc.).

  1. Disconnect from the MySQL server. Once you have finished listing the databases, you can disconnect from the MySQL server by typing exit at the MySQL prompt:
mysql> exit

Alternatively, you can use the mysql utility with the -e option to list the databases directly from the command line, without connecting to the MySQL server:

mysql -u root -p -e "SHOW DATABASES"

This will list the databases on the MySQL server without the need to connect to the MySQL server.

Created Time:2017-10-30 10:17:51  Author:lautturi