mySQL server connection, disconnection and cmd operation

mySQL server connection, disconnection and cmd operation

Use the mysql command to connect to the MySQL server. After the MySQL server is started, select "Start" → "Run" command, enter the "cmd" command in the pop-up "Run" window, press Enter to enter the DOS window, and enter the command prompt to connect to the MySQL server. Test website www.dc3688.com

To connect to the MySQL server, you need to enter the username, password, and address of the MySQL server.

>mysql-uroot-h127.0.0.1-ppassword

Disconnect

After connecting to the MySQL server, you can disconnect from the MySQL connection by entering the "exit" or "quit" command at the MySQL prompt.

mysql>quit

Supplementary knowledge: MySQL client commands and server commands

There are two forms of executing commands in the mysql client. One is the client command and the other is the server command

The client command does not need to end with ";", just write it directly, and can be abbreviated

You can view client commands through the help command

When we were learning awk, we learned the system function, which is to call Linux commands in awk. We can indirectly call other commands through the system command, for example: system hostname, so that we don't have to exit the Linux terminal and come back when we want to execute the command. It is more convenient. Many tools are very similar in some places. This is also very useful.

This command is a prompt, it can change our prompt, similar to PS1, it can modify the prompt format

In the script, we can use source to make the configuration file effective. We can also use this method in MySQL. For example, we write a test (vim test.sql). Note that the SQL command we are using now is generally a MySQL operation command. It is generally recommended that if you write MySQL operation commands in a file, you should add a sql suffix, just like we wrote the test.sh. This is the sql script.

If the sql script is saved in the current directory, the current path can be omitted, but if it is not saved in the current directory, you can write its path, otherwise it will not know where to save it.

The server-side command needs to be ended with; Press Enter to execute, and the semicolon must be added

-A, --no-auto-rehash disable completion

-u, --user=username, default is root

-h, --host= server host, default is localhost

-p, --passowrd= user password, it is recommended to use -p, the default is an empty password

-P, --port=SERVER_PORT

-S, --socket= specifies the connection socket file path

-D, --database= Specify the default database

-C, --compress enable compression

-e "SQL" Execute SQL command

-V, --version show version

-v --verbose Show detailed information

–print-defaults Get the default configuration used by the program

The above article about mySQL server connection, disconnection and cmd usage is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • Perfect solution to the problem that MySQL cannot connect to the database through localhost
  • Causes and solutions for slow MySQL query speed and poor performance
  • How to implement Python MySQL disconnection and reconnection
  • Solve the problem of MySQL server actively disconnecting when there is no operation timeout

<<:  Vue3 Vue Event Handling Guide

>>:  How to build LNMP environment on Ubuntu 20.04

Blog    

Recommend

MySQL 8.0.21.0 Community Edition Installation Tutorial (Detailed Illustrations)

1. Download MySQL Log in to the MySQL official we...

A brief analysis of Linux network programming functions

Table of contents 1. Create a socket 2. Bind sock...

How to embed other web pages in a web page using iframe

How to use iframe: Copy code The code is as follo...

Tutorial diagram of using Jenkins for automated deployment under Windows

Today we will talk about how to use Jenkins+power...

Docker builds Redis5.0 and mounts data

Table of contents 1. Simple mounting of persisten...

Detailed example of using typescript to encapsulate axios in Vue3

This axios package is used in the vue3 demo. For ...

How to add rounded borders to div elements

As shown below: CSS CodeCopy content to clipboard...

MySQL SQL statement to find duplicate data based on one or more fields

SQL finds all duplicate records in a table 1. The...

Example of how to change the domestic source in Ubuntu 18.04

Ubuntu's own source is from China, so the dow...

CSS implements 0.5px lines to solve mobile compatibility issues (recommended)

【content】: 1. Use background-image gradient style...

Understand the principles of MySQL persistence and rollback in one article

Table of contents redo log Why do we need to upda...

Detailed explanation of how to enter and exit the Docker container

1 Start the Docker service First you need to know...

Analysis of the principles of docker containers

Table of contents 01 What is the essence of a con...