Home > Database > Mysql Tutorial > body text

Where to open mysql command line

下次还敢
Release: 2024-04-14 18:51:51
Original
564 people have browsed it

To open MySQL from the command line, follow these steps: Open a command prompt or terminal. Enter the MySQL command: mysql -u -p. Enter your password (if set). Enter SELECT VERSION(); to view the MySQL version and confirm that it is connected. Type exit to exit MySQL.

Where to open mysql command line

How to open MySQL in the command line

Opening MySQL in the command line is very simple, just follow the following Steps:

1. Open the command prompt or terminal

  • On Windows, press the Windows key R, enter cmd, and then press Enter.
  • On macOS and Linux, open the Terminal application.

2. Enter the MySQL command

In the command prompt or terminal, enter the following command:

<code>mysql -u <用户名> -p</code>
Copy after login

Where:

  • <Username> is the MySQL username you created.
  • <Password> is the MySQL password you set.

3. Enter the password

If you set a password when installing MySQL, the system will prompt you to enter the password. After entering the password, press Enter.

4. Now that you are connected to MySQL

Enter the following command to view the MySQL version:

<code>SELECT VERSION();</code>
Copy after login

You will see output similar to the following:

<code>+-----------+
| VERSION() |
+-----------+
| 8.0.27    |
+-----------+</code>
Copy after login

This means you have successfully connected to MySQL. You can continue to enter MySQL commands to manage your database.

5. Exit MySQL

To exit MySQL, enter the following command:

<code>exit</code>
Copy after login

The above is the detailed content of Where to open mysql command line. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!