![]() Run the following command on your terminal to show a list of all databases: mysql -u user -p -e 'show databases ' +-+ This is especially usefully when you want to work with your MySQL databases using shell scripts. That displays databases and tables information. ![]() ![]() To get a list of the databases without logging in to the MySQL shell you can use either the mysql command with the -e option which stands for execute or the mysqlshow Show MySQL Databases from the Command Line # The following statement will give you a list of all databases that starts with either “open” or “word”: SELECT schema_name FROM information_schema.schemata WHERE schema_name LIKE 'open%' OR schema_name LIKE 'word%' +-+ If you want to make a more complex search you query the schemata table from the information_schema database which contains information about all databases. The percent sign ( %) means zero, one, or multiple characters. SHOW DATABASES LIKE pattern įor example, the following statement will return all databases which names starts with ‘open’: SHOW DATABASES LIKE 'open%' +-+ The LIKE clause can be used to filter the output of the SHOW DATABASES command according to a specific pattern. You’ll see a list of all the databases on the MySQL server: +-+ Run the SHOW DATABASES command: SHOW DATABASES Log in a MySQL root user: mysql -u user -p To list all the databases on the MySQL server you’ll need to login as a user that can access all databases, by default that is the MySQL root user or set a global SHOW DATABASES privilege. The output will be the same as when using the SHOW DATABASES command: +-+ The output will be similar to this: +-+Īnother command that you can use to list the databases is SHOW SCHEMAS which is a synonym for the SHOW DATABASES command: SHOW SCHEMAS The command will print a list of all the databases for which the user have some kind of a privilege granted to If you haven’t set a password for your MySQL user you can omit the -p switch.įrom within the MySQL shell execute the following command: SHOW DATABASES
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |