How to Run MySQL on Command Prompt

how to run MySQL on cli If you want to learn how to run MySQL on command prompt, this is a quick tutorial that will guide you on how you can start MySQL running on command prompt and a accomplish lots of other database management tasks using the CLI.

If you are running WordPress, you can Create MySQL Database WordPress via Command Line as I explained and illustrated in that tutorial.

For WordPress users you can also learn how to connect MySQL to WordPress during WordPress installation as I explained on this guide  – Connect WordPress to MySQL Database Step by Step

How to Run MySQL on Command Prompt

The following are the steps you should follow to run MySQL on command prompt :
  1. First open Command prompt from the search bar on your Windows machine by typing CMD as shown on the screenshot below :how to run MySQL on command prompt
  2. After you open the command prompt you need to ensure MySQL is running in your local server. For example in the previous tutorial I used XAMMP to illustrate how you can access the folder where MySQL is located for you to run it.  If you missed that tutorial, you can check it out here – Create MySQL Database WordPress via Command Line. Today, I am using a different localhost environment a lightweight server called laragon. how to run mysql on command prompt cli So as you can see on the image above need to navigate to directory where the MySQL is located.
  3. Now you can start MySQL in Windows Command prompt using the following command: mysql.exe –u<username> –p
  4. You should replace the -u and -p with the respective username and password of your MySql database.  If you have followed all the steps in the right way you should successfully run MySQL on command prompt.
  5. In my case you can see that I added the username and the password and MySQL run successfully and you can now go  ahead to user other MySQL command prompt commands to access the databases and manage the data.run MySQL on cli

Conclusion

In this tutorial, I have explained how to run MySQL on command prompt in Windows. The most important step that you should remember is the location of your MySQL installation. This in most cases its located inside a folder named Bin that is in you local server installation root.  I hope this tutorial helps you learn more how to use MySQL on command prompt.

Similar Articles

  1. How to Create MySQL Database WordPress via Command Line
  2. How to Setup WooCommerce Storefront Blog