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

Recommend

Usage of Linux userdel command

1. Command Introduction The userdel (user delete)...

Summary of the use of Vue computed properties and listeners

1. Computed properties and listeners 1.1 Computed...

Detailed explanation of Vue3.0 + TypeScript + Vite first experience

Table of contents Project Creation Project Struct...

How to configure jdk environment under Linux

1. Go to the official website to download the jdk...

Detailed explanation of Grid layout and Flex layout of display in CSS3

Gird layout has some similarities with Flex layou...

Solve the problem of OpenLayers 3 loading vector map source

1. Vector Map Vector graphics use straight lines ...

How to limit the input box to only input pure numbers in HTML

Limit input box to only pure numbers 1、onkeyup = ...

Docker Nginx container production and deployment implementation method

Quick Start 1. Find the nginx image on Docker Hub...

Analysis of the difference between Mysql InnoDB and MyISAM

MySQL supports many types of tables (i.e. storage...

Linux uses iftop to monitor network card traffic in real time

Linux uses iftop to monitor the traffic of the ne...

Solution to forgetting the administrator password of mysql database

1. Enter the command mysqld --skip-grant-tables (...

Even a novice can understand the difference between typeof and instanceof in js

Table of contents 1. typeof 2. instanceof 3. Diff...

Detailed steps to build an NFS file sharing server in Linux

Linux builds NFS server In order to achieve data ...