MySQL (a)-Client side-related

Source: Internet
Author: User
Tags mysql client

Version

CentOS Linux release 7.4.1708 (Core)       内核  3.10.0-693.el7.x86_64Ver 15.1 Distrib 5.5.56-MariaDB以yum方式安装
Client directives
Long command shortcut abbreviation? (\?) Synonym for ' help '. Display assistance Clear (\c) clear the current input statement.connect (\ r) reconnect to the server. Optional arguments is DB and Host.delimiter (\d) Set statement Delimiter.edit (\e) Edit command with $EDITOR. Using a system-defined $EDITOR Editor as a command operation ego (\g) Send command to MySQL server, display result Vertically.exit (\q) exit MySQL. Same as quit. Exit the client Go (\g) Send command to the MySQL server.help (\h) display this assist. Show Help Nopager (\ n) Disable Pager, print to stdout.notee (\ t) Don ' t write into Outfile.pager (\p) Set Pager [To_pager].      Print the query results via Pager.print (\p) print current command.prompt (\ r) Change your MySQL prompt. Changing the prompt Quit (\q) Quit MySQL. Exit client Rehash (\#) Rebuild completion Hash.source (\.) Execute an SQL script file. Takes a file name as an argument. Import SQL Script status (\s) Get status information from the server. Displays information about the current MySQL server system (\ !) Execute a System shell command. Execute operating system Command Tee (\ t) Set outfile [To_outfile]. Append everything into given outfile.use (\u) use another database. Takes database name as argument. Toggles the specified DB charset (\c) switch to another charset. Might is needed for processing binlog with Multi-Byte charsets. The character set when the connection is changed. CharSet Utf8;warnings (\w) show warnings after every statement.nowarning (\w) Don ' t Show warnings after every statement.

Simple demo of several MySQL client commands

MariaDB [mysql]> system hostname7-db-1MariaDB [mysql]> \! hostname7-db-1
Change the MySQL prompt
Man MySQL find prompt
Parameter
Description
\d The full date
\d Current database
\h Server name
\u Current user
\p Current port number
\u Current full name [email protected]_name
\v Database version
\m Current minute
\s Current seconds
\ r Current hour, 24-hour system (0–23)
\ r Current hour, 12-hour system (1-12)
\p (uppercase) am/pm
\w Current Week (Mon, Tue, ...)
\o Current month (1-12)
\o (uppercase) Current month (Jan, Feb, ...)
\y Current year, 2 digits (18)
\y Current year, 4 digits (2018)
\s (uppercase) Semicolon
\ t Tab delimiter
\ n Line break
\_ A space
\ A space containing \ backslash
\′ A single quotation mark
\" A double quote
\\ A \ Backslash
\ any character Any character is displayed

Method One: The client is connected by the parameter specified to modify

mysql --prompt="(\[email protected]\h) [\d]> "

Method Two: After connecting the client, modify by the prompt command

mysql> prompt (\[email protected]\h) [\d]>\_

Method Three: Modify by global variables

export MYSQL_PS1="(\[email protected]\h) [\d]> "

Method Four: Through the configuration file modification, notice the front more backslash

/etc/my.cnf or  [mysql]  prompt=(\\[email protected]\\h) [\\d]>\\_
Initialize security settings
mysql_secure_installation  然后按提示完成
Connecting to a database
# mysql-u root-h 127.0.0.1-p123456-d mysql-e-P 3306 Common Options-H server address-u user name,-u and user name can be separated by a space-p in clear text to specify the password, between-p and password cannot have space-p (large  Write) service-side Port-S mysql.sock socket path, single-use multi-instance to the-D database name, log in and switch directly to the specified database, instead of using DATABASE;-C data compression Transfer-e non-interactive mode Execute SQL statement, followed by SQL statement # MySQL    -U root-p123456-d mysql-e ' select User,host,password from user; ' +------+-----------+-------------------------------------------+    | user | Host |    password | +------+-----------+-------------------------------------------+    | Root | localhost |    *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 | | Root | 127.0.0.1 |    *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 | | Root | :: 1 |    *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 | +------+-----------+-------------------------------------------+-e: Query results are displayed vertically ********************** 3. Row *************************** Host::: 1 user:root Password: *6bb4837eb74 329105EE4568DDA7DC67ED2CA2AD9 SELECT_PRIv:y insert_priv:y update_priv:y delete_priv:y create_priv:y--protocol={tcp|s Ocket| pipe| MEMORY}:
Log in by bypassing the MySQL password
1.修改当前mysql数据库的配置文件,添加以下选项[mysqld]skip-grant-tables2.重启mysql服务以此种方式启动的mysql不可以使用内置的授权指令创建用户和修改密码,只能使得update表修改,记得最后刷新权限表。修改完之后,记录删除这个选项。
Client Configuration
# vim /etc/my.cnf.d/client.cnf [client]user=root                       指定用户名password=123456                 指定密码default-character-set= utf8  指定默认连接的字符集

MySQL (a)-Client side-related

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.