{"id":27102,"date":"2018-06-08T04:35:06","date_gmt":"2018-06-08T09:35:06","guid":{"rendered":"https:\/\/www.rosehosting.com\/blog\/?p=27102"},"modified":"2022-06-03T03:34:56","modified_gmt":"2022-06-03T08:34:56","slug":"how-to-list-all-databases-in-mysql","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/how-to-list-all-databases-in-mysql\/","title":{"rendered":"How To Show A List Of All DataBases In MySQL"},"content":{"rendered":"
<\/p>\r\n
We will show you how to list all databases in MySQL, i.e how to have a list of all MySQL databases. MySQL is an open-source relational database management system commonly used with web-based applications like WordPress, Magento, etc. In this tutorial, we will show you how to list all databases in MySQL on a Linux VPS<\/a>.<\/p>\r\n <\/p>\r\n Before you start listing all tables in MySQL, make sure that you have full root access to your Linux server, or at least you have a system user with sudo privileges<\/a> that you can use to connect to your server. Once you connect to your server via SSH<\/a> run the following command to check whether you have a MySQL database server installed<\/a> on your VPS and what is the version:<\/p>\r\n The output of the command should be similar to the one below:<\/p>\r\n Next, to connect to the MySQL database server through the command line as user MySQL will ask you to enter the password for the MySQL root user. Enter the password and press Of course, it is always recommended to keep your services secure, so if you haven’t set up the MySQL root password<\/a> yet, you can do that now using the Then, answer the security questions as follows:<\/p>\r\n Then, connect to the MySQL database server using the MySQL root user and enter your new root password.<\/p>\r\n This command will work for you no matter if you have an Ubuntu VPS<\/a> or CentOS VPS<\/a>.<\/p>\r\n The output of the command should be similar to the one below:<\/p>\r\n If you have other databases created in MySQL, they will be all listed here. To list the tables, you can use the command below:<\/p>\r\n The tables will be listed in the following format:<\/p>\r\n If you want to find out about the structure of a specific table you can use the The output will show you information about each of the columns in the table.<\/p>\r\n If you want to go a little further and learn more about how to use the MySQL database service you can also check our tutorials on how to show all users in MySQL<\/a> or how to create a new user in MySQL and grant permissions to a MySQL database<\/a>. Advanced topics include how to configure remote and secure connections for MySQL<\/a> as well as how to optimize and repair MySQL databases with mysqlcheck<\/a>.<\/p>\r\n Of course, you don\u2019t have to list all tables in MySQL,\u00a0 if you are using one of our MySQL VPS Hosting<\/a> services, in which case you can simply ask our expert Linux admins to help you. They are available 24\u00d77 and will take care of your request immediately.<\/p>\r\n PS. If you liked this post on how to list all databases in MySQL on a Linux VPS, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.<\/p>\r\n\r\n <\/p>\r\n","protected":false},"excerpt":{"rendered":" We will show you how to list all databases in MySQL, i.e how to have a list of all MySQL … <\/p>\nmysql -V<\/pre>\r\n
# mysql -V\r\nmysql Ver 14.14 Distrib 5.7.22, for Linux (x86_64) using EditLine wrapper<\/pre>\r\n
root<\/code> run the following command:<\/p>\r\n
mysql -u root -p<\/pre>\r\n
Enter<\/code>. If you haven’t already set up a password for the MySQL root user, you can use the following command:<\/p>\r\n
mysql -u root<\/pre>\r\n
mysql_secure_installation<\/code> command without arguments:<\/p>\r\n
mysql_secure_installation<\/pre>\r\n
Would you like to setup VALIDATE PASSWORD plugin?\r\nPress y|Y for Yes, any other key for No: y\r\n\r\nPlease set the password for root here.\r\nNew password:\r\n\r\nDo you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y\r\n\r\nRemove anonymous users? (Press y|Y for Yes, any other key for No) : y\r\n\r\nDisallow root login remotely? (Press y|Y for Yes, any other key for No) : y\r\n\r\nRemove test database and access to it? (Press y|Y for Yes, any other key for No) : y\r\n\r\nReload privilege tables now? (Press y|Y for Yes, any other key for No) : y\r\n\r\nAll done!\r\n<\/pre>\r\n
To list all databases in MySQL, run the following command:<\/h2>\r\n
mysql> show databases;<\/pre>\r\n
mysql> show databases;\r\n+--------------------+\r\n| Database |\r\n+--------------------+\r\n| information_schema |\r\n| mysql |\r\n| performance_schema |\r\n| sys |\r\n+--------------------+\r\n4 rows in set (0.00 sec)\r\n<\/pre>\r\n
Next, if you want to use a specific database and list all tables in it, you can use the following commands:<\/p>\r\nmysql> use mysql;\r\n<\/pre>\r\n
mysql> show tables<\/pre>\r\n
mysql> show tables;\r\n+---------------------------+\r\n| Tables_in_mysql |\r\n+---------------------------+\r\n| columns_priv |\r\n| db |\r\n| engine_cost |\r\n| event |\r\n| func |\r\n| general_log |\r\n| gtid_executed |\r\n| help_category |\r\n| help_keyword |\r\n| help_relation |\r\n| help_topic |\r\n| host |\r\n| innodb_index_stats |\r\n| innodb_table_stats |\r\n| ndb_binlog_index |\r\n| plugin |\r\n| proc |\r\n| procs_priv |\r\n| proxies_priv |\r\n| server_cost |\r\n| servers |\r\n| slave_master_info |\r\n| slave_relay_log_info |\r\n| slave_worker_info |\r\n| slow_log |\r\n| tables_priv |\r\n| time_zone |\r\n| time_zone_leap_second |\r\n| time_zone_name |\r\n| time_zone_transition |\r\n| time_zone_transition_type |\r\n| user |\r\n+---------------------------+\r\n32 rows in set (0.00 sec)\r\n<\/pre>\r\n
DESCRIBE<\/code> statement in MySQL:<\/p>\r\n
mysql> DESCRIBE user;<\/pre>\r\n
\r\n