devxlogo

Connecting to a MySQL Database from the Command Prompt

Connecting to a MySQL Database from the Command Prompt

Connecting to a MySQL database from the command prompt can be very easy:

[root@mypc]#mysql -S /opt/db/mysql//mysql.sock -uroot -prootPassword

Here, we are trying to connect to the MySQL database

  1. Installed in location /opt/db/
  2. Database Name is the database name
  3. -u indicates the parameter username, i.e. in this case it is root
  4. -p indicates the parameter password, in this case it is rootPassword

Most importantly, we are connecting using sockets, which is faster than any other type of connection.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist