Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

To list MySQL databases without opening an interactive prompt, run mysql -u USER -p -e "SHOW DATABASES;". The client asks for the password, executes the statement, prints the databases visible to that account, and exits. Add -h HOST for a remote server and -P PORT when the server listens on a nondefault port.

The quickest command-line methods

There are three practical ways to list databases from a shell. The first two use the MySQL client and the SHOW DATABASES statement; the third uses the separate mysqlshow utility.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Method Example Best for
Noninteractive SQL mysql -u USER -p -e "SHOW DATABASES;" One command, scripts, and automation
Interactive SQL mysql -u USER -p, then SHOW DATABASES; Exploring several statements in one session
mysqlshow mysqlshow -u USER -p -h HOST A utility that directly prints database names

All three methods apply the same visibility rule: the server normally returns databases on which the connected account has some privilege, rather than promising a complete server-wide inventory.

List databases without opening the mysql> prompt

Use the client’s -e (long form: --execute) option:

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application: attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Economical &Reusable: Built durable materials with a long-lasting battery,our CAGIWIRU air duster it's a sustainable alternative to disposable air cans.
mysql -u USER -p -e "SHOW DATABASES;"

The SQL is passed as one shell argument, executed by the server, and the client exits after displaying the result. Replace USER with the MySQL account name. The -p option causes the client to request the password interactively; it does not require you to place the password in the command line.

Keep the SQL in quotes. The statement contains a space, and quoting also protects characters such as *, %, parentheses, or shell operators when you later add a filter. The semicolon terminates the SQL statement. It is conventional and makes the command unambiguous when more SQL is appended.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Connect to a remote host

Supply the server name or address with -h:

mysql -u USER -p -h HOST -e "SHOW DATABASES;"

For a server using a nondefault TCP port, add uppercase -P followed by the port number:

mysql -u USER -p -h HOST -P PORT -e "SHOW DATABASES;"

For example, the shape of a remote command is:

mysql -u reporting -p -h db.example.net -P 3307 -e "SHOW DATABASES;"

The host and port identify where the client should connect; the account and its privileges determine which database names the server will return.

Use an interactive MySQL session

Start the client without -e when you want to run more than one statement:

mysql -u USER -p

After entering the password, wait for the mysql> prompt and enter:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
SHOW DATABASES;

The result is a table containing the database names visible to that account. You can then run another SQL statement in the same connection, or leave the client with exit or quit.

Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
  • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
  • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
  • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
  • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth

Interactive mode is useful when listing databases is only the first check—for example, when you need to select one and inspect its tables afterward. It is less convenient for a script because a person must start the session, supply input, and terminate it.

SHOW SCHEMAS is equivalent

MySQL treats SHOW SCHEMAS; as a synonym for SHOW DATABASES;. Either spelling can be entered at the prompt or passed to --execute:

mysql -u USER -p -e "SHOW SCHEMAS;"

The two statements use the same connection and privilege rules. Choose the wording that best matches the terminology used by your team or SQL scripts.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use mysqlshow as a dedicated listing utility

The separate mysqlshow program can list database names directly. When you do not give it a database argument, it displays a list of database names:

mysqlshow -u USER -p -h HOST

Add -P PORT for a nondefault port:

mysqlshow -u USER -p -h HOST -P PORT

Like SHOW DATABASES, mysqlshow shows only databases for which the account has privileges. It is convenient when you want a utility wrapper rather than writing SQL, while mysql -e is the more flexible choice when you need a filter or want to combine this query with other statements.

Choose the right connection options

The same listing statement can be used against a local or remote server. These are the options that matter for this task:

Option Purpose Example
-u USER Selects the MySQL account name -u appreader
-p Prompts for the account password -p
-h HOST Names the MySQL server host -h db.internal
-P PORT Selects a nondefault server port -P 3307
-e SQL or --execute=SQL Runs SQL and exits -e "SHOW DATABASES;"

Option order is flexible as long as the option values stay attached to their options. Keeping the connection options before -e makes commands easier to read. If your shell treats a character specially, quote the complete SQL argument rather than relying on the shell to preserve it.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black | LED mouse pad with 14 lighting modes, covers keyboard & mouse, anti-slip rubber base, waterproof surface, USB powered
  • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
  • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
  • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
  • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
  • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.

Filter the database list

For a large server, listing every visible name may be unnecessary. MySQL allows a pattern with LIKE:

mysql -u USER -p -e "SHOW DATABASES LIKE 'app%';"

In this example, app% matches names beginning with app. The percent sign is a SQL wildcard, so enclosing the complete statement in double quotes prevents the shell from interpreting it before MySQL receives it. The single quotes around the pattern are SQL string delimiters.

Use a WHERE expression when a pattern alone is not enough:

mysql -u USER -p -e "SHOW DATABASES WHERE `Database` LIKE 'app%';"

The LIKE form is concise for prefix, suffix, or substring searches. The WHERE form lets you express a more general condition against the result column. Keep the backticks around Database in shell examples so the column name is passed exactly as written.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Filtering does not expand visibility. It only narrows the rows that the server would otherwise return for that account.

Why the command may not show every database

Account privileges control visibility

MySQL normally shows databases on which the connected account has some privilege. A successful connection therefore does not imply that the result is a complete list of databases on the server. Two accounts can run the same command and receive different lists.

If an application database is absent, first confirm that you connected with the intended account and host. Then ask a MySQL administrator to verify that the account has a privilege on that database or to grant the appropriate access. Changing the SQL spelling will not reveal a database that the account is not allowed to see.

Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
  • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
  • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
  • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
  • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.

The SHOW DATABASES privilege

The global SHOW DATABASES privilege permits broader visibility. Whether it is appropriate depends on the server’s security policy: granting it can reveal database names that the account otherwise would not see. Request it only when the account genuinely needs a server-wide inventory.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The --skip-show-database server setting

If the server was started with --skip-show-database, the SHOW DATABASES statement cannot be used unless the account has the SHOW DATABASES privilege. In that configuration, an account that merely has privileges on individual databases may still be unable to obtain the list through this statement.

This is a server-side setting, not a client option. If you encounter this restriction, an administrator must review the account privileges or the server configuration; adding -h, -P, or a different filter will not bypass it.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common command-line failures

“command not found” or an unavailable client

If the shell cannot find mysql or mysqlshow, the MySQL client programs are not available through the current executable path. Install or enable the client package appropriate to your operating system, or invoke the client using its full path. This problem occurs before a database query is sent, so changing SHOW DATABASES will not help.

Access denied

An access-denied error indicates that authentication failed or that the account is not permitted to connect in the way requested. Recheck the user name, password, host name, and port. If the account authenticates successfully but the list is incomplete, investigate database privileges separately; authentication and database visibility are different checks.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Unable to connect to the server

For a connection error, verify that -h names the intended server and that -P matches the port on which that server accepts connections. A remote server may also restrict which client hosts can connect. Test the connection details with the administrator before changing the SQL statement.

The command returns an unexpected short list

Check whether you are using a restricted account, whether you connected to a different host than expected, and whether the server uses --skip-show-database. Run the unfiltered statement first; a LIKE or WHERE condition can hide names that would otherwise be visible.

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.

The shell changes the query

Quote the complete SQL argument, especially when it contains spaces, percent signs, parentheses, backticks, or comparison operators. For example:

mysql -u USER -p -e "SHOW DATABASES LIKE 'app%';"

Using the wrong quote style can cause the shell to expand a wildcard or treat part of the SQL as a separate argument. If a command behaves differently from the same statement at the mysql> prompt, inspect the shell quoting first.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use the command safely in scripts

The noninteractive form is designed for scripting because it performs one query and terminates:

mysql -u USER -p -h HOST -P PORT -e "SHOW DATABASES;"

A script can capture or redirect the command’s output using normal shell features. Keep the password prompt interactive unless your environment has an approved, protected credential mechanism. Do not place a real password directly after -p in a command that may be stored in shell history or visible in process listings.

Use a narrowly scoped account for automation. A listing job that only needs to discover databases should not automatically receive write privileges. If the job must see every database, coordinate the required visibility with an administrator rather than assuming that a normal application account can provide a server-wide list.

When diagnosing automation, run the exact command manually first, then add redirection or scheduling. This separates connection, privilege, and shell-quoting problems from issues introduced by the surrounding script.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Interactive versus noninteractive versus mysqlshow

Question mysql -e Interactive mysql mysqlshow
Does it open the mysql> prompt? No Yes No
Does it execute the canonical SQL statement? Yes, through -e Yes, when you enter SHOW DATABASES; It uses the client utility to list names
Can you add a LIKE or WHERE filter? Yes Yes The direct listing form is less suitable for SQL expressions
Can you provide host and port options? Yes, with -h and -P Yes, with -h and -P Yes, with -h and -P
Which databases are shown? Those visible to the connected account, subject to the server’s SHOW DATABASES privilege and --skip-show-database setting

For a single command or scheduled check, use mysql -e. For exploratory work that will continue into other SQL statements, use an interactive session. Choose mysqlshow when a small command-line utility is more convenient than writing the SQL yourself.

A practical checklist

  • Confirm that the mysql client is installed and available in the shell.
  • Choose the MySQL account whose visibility you need.
  • Use -h HOST for the intended server and -P PORT when its port is nondefault.
  • Run mysql -u USER -p -e "SHOW DATABASES;" for a one-shot listing.
  • Use SHOW SCHEMAS; if that synonym fits your SQL style.
  • Add LIKE or a WHERE expression when you need a filtered result.
  • If names are missing, check account privileges and the server’s --skip-show-database setting.
  • Use mysqlshow -u USER -p -h HOST when you prefer the dedicated utility.

Which command should you use?

For most command-line questions, use mysql -u USER -p -e "SHOW DATABASES;". It is the canonical SQL query in a form that works from a shell, can be directed at a named host and port, and can be extended with SQL filters. Remember that its output is a privilege-filtered view, not automatically a complete inventory of the server. Use an interactive session for follow-up SQL, or mysqlshow when a direct listing utility better fits your workflow.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.