MySQL login and exit command format

MySQL login and exit command format

The command format for mysql login is:

mysql -h [hostip] -u [username] -p [password] [database]

1. Normal login mysql database command format: mysql -u username-p password, for example: mysql -u root -p root
root mysql -u root -p root
If no password is provided after -p, the user will be asked to enter the password after executing the command.

這里寫圖片描述

2. Set the port number to log in. The default port number of MySQL is 3306.
The command format is: mysql -u username-p password-P port number. Note that the letter P that specifies the port is uppercase, while the letter p that identifies the password is lowercase.

這里寫圖片描述

3. Specify the IP address and port number to log in to the MySQL database. The command format is: mysql -h ip -u user -p -P port number. For example: mysql -h 127.0.0.1 -u root -p -P 3306

這里寫圖片描述
這里寫圖片描述

4. Create a database login
mysql -h ip address -u username -p password database name For example: mysql -h 127.0.0.1 -u root -p test

View the currently logged in user and database

查看當前登陸用戶和數據庫命令

select user();
  select database();

Exit the login command and log in to MySQL. After entering, you may see the following prompt message. You can use help to see the output results.

mysql> help

For information about MySQL products and services, visit:
  http://www.mysql.com/
For developer information, including the MySQL Reference Manual, visit:
  http://dev.mysql.com/
To buy MySQL Enterprise support, training, or other products, visit:
  https://shop.mysql.com/

List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
? (\?) Synonym for `help'.
clear (\c) Clear the current input statement.
connect (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter.
edit (\e) Edit command with $EDITOR.
ego (\G) Send command to mysql server, display result vertically.
exit (\q) Exit mysql. Same as quit.
go (\g) Send command to mysql server.
help (\h) Display this 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.
quit (\q) Quit mysql.
rehash (\#) Rebuild completion hash.
source (\.) Execute an SQL script file. Takes a file name as an argument.
status (\s) Get status information from the server.
system (\!) Execute a system shell command.
tee (\T) Set outfile [to_outfile]. Append everything into given outfile.
use (\u) Use another database. Takes database name as argument.
charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
warnings (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.
resetconnection(\x) Clean session context.

For server side help, type 'help contents'

Through the output information, we know the following three commands to exit mysql
1. exit
2. quit
3. \q

This is the end of this article about the MySQL login and exit command format. For more relevant MySQL login and exit content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Solution to the problem that MySQL commands cannot be entered in Chinese
  • Detailed explanation of encoding issues during MySQL command line operations
  • Introduction to the use of MySQL source command
  • MySQL commonly used SQL and commands from entry to deleting database and running away
  • Implementation of mysql using mysqlbinlog command to restore accidentally deleted data
  • Introduction to query commands for MySQL stored procedures
  • Three methods of automatically completing commands in MySQL database
  • MySQL password contains special characters & operation of logging in from command line
  • Mysql desktop tool SQLyog resources and activation methods say goodbye to the black and white command line
  • How to use the MySQL authorization command grant
  • Summary of MySQL basic common commands

<<:  Nginx local directory mapping implementation code example

>>:  Detailed explanation of component development of Vue drop-down menu

Recommend

Example of disabling browser cache configuration in Vue project

When releasing a project, you will often encounte...

The easiest way to debug stored procedures in Mysql

A colleague once told me to use a temporary table...

User needs lead to marketing-oriented design

<br />For each of our topics, the team will ...

Two solutions for automatically adding 0 to js regular format date and time

Table of contents background Solution 1 Ideas: Co...

In-depth interpretation of /etc/fstab file in Linux system

Preface [root@localhost ~]# cat /etc/fstab # # /e...

MySQL 5.7.18 zip version installation tutorial

The mysql 5.7.18 zip version of MySQL is not like...

Pure CSS3 to create page switching effect example code

The one I wrote before is too complicated, let’s ...

Detailed explanation of the middleman mode of Angular components

Table of contents 1. Middleman Model 2. Examples ...

HTML table markup tutorial (22): row border color attribute BORDERCOLORLIGHT

Within rows, light border colors can be defined i...

Some suggestions for improving Nginx performance

If your web application runs on only one machine,...

Detailed explanation of Linux redirection usage

I believe that everyone needs to copy and paste d...

vue-admin-template dynamic routing implementation example

Provide login and obtain user information data in...

MySQL index coverage example analysis

This article describes MySQL index coverage with ...

Use Python to connect to MySQL database using the pymysql module

Install pymysql pip install pymysql 2|0Using pymy...