If you're a developer working with databases, you're probably familiar with MySQL - an open-source relational database management system. While there are many ways to access a MySQL database, one of the most straightforward methods is through the MySQL terminal command. #terminal #mysql

To access a MySQL database through the terminal, follow these simple steps:

  1. Open your terminal and enter the command mysql -u [username] -p. This will open the MySQL client and prompt you to enter your password. Replace [username] with your MySQL username.
  2. Once you've entered your password, you'll see the MySQL prompt, which looks like this: mysql>. This means you're now connected to your MySQL database.
  3. To access a specific database, use the USE command followed by the name of the database. For example, USE mydatabase;.
  4. You can now run MySQL commands to view, modify, or delete data in your database. For example, to view all the tables in your database, use the command SHOW TABLES;.
  5. When you're finished working with the database, use the EXIT command to exit the MySQL client.

MySQL terminal command

While using the MySQL terminal command may seem intimidating at first, it's a powerful tool that can help you manage your MySQL databases more efficiently. Whether you're working on a personal project or a large-scale application, knowing how to access a MySQL database through the terminal can be a valuable skill for any developer. If you are not logged in as root you can access a database like this. You will be prompted for a password to that particular database.
mysql -u [username] -p [database]
Complete Cheat Sheet  


Sign Up To Comment