Get the App
SLTechnology News&Howtos  ›  Database  › 

Getting started with MySQL-how to invoke command line commands

Shulou Source: shulou.com Published: 2022-06-01 06:26:54 10月05日 Update

How to invoke command line commands (mysql\ mysqldump\ mysqladmin\ mysqlimport)

Angular mysql is a generic command-line client that sends SQL statements to the server, including SQL statements for administration.

Z. mysqladmin is an administrative command-line client that helps manage the server.

Z. mysqlimport provides a command-line interface for LOAD DATA INFILE statements. Using this client, you can load data files into a table without manually issuing LOAD DATA INFILE statements.

Z. mysqldump is a command-line client that dumps the contents of the database and tables. Use it to back up the database or copy it to another computer.

1) how to use the mysql client

Shell > mysql-- help

2) query the running MySQL distribution version

Shell > mysql-V

Mysql Ver 14.14 Distrib 5.6.10, for Linux (x86 / 64) using EditLine wrapper

The version of the client program running is not necessarily the same as the version of the server.

3) connection parameter options

Connect through a specified host: locally connect to a server running on the same host, and remotely connect to a server running on another host

Common client-specific connection options:

-h or-- host=

-C or-- compress

-- protocol=

-P or-- port=

-S or-- socket=

-- shared-memory-base-name=

Some of the most common connection parameter options are listed below:

-h: followed by the hostname or IP address of a given host to connect to the server (default is localhost)

-C: compress all information sent between the client and the server (if both support compression)

-- protocol: followed by the connection protocol used to connect to the server: {TCP | SOCKET | PIPE | MEMORY}

-P: followed by the port number, instead of the default value (3306)

-S: used to set the name of the UNIX socket file or named pipe used on Windows

-- shared-memory-base-name: (Windows only) the name of the shared memory used when connecting to the local server through shared memory. This option applies only if the server supports shared memory connections.

The following examples show how to use some of the options above:

Mysql-h 192.168.1.101-P 3351-u root-p

Mysql-host=localhost-compress

Mysql-- host=localhost-S / var/lib/mysql/mysql.sock

Mysql-protocol=TCP

Tags: Server service client client command host statement run memory follow data version management parameter name common database file support same Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL OPPO Reno Shulou Information NVidia Shulou Technology