Linux basic command-mysql
mysql
MySQL is a simple sql shell that can be used to manage mysql databases.
This command applies to Red Hat, RHEL, Ubuntu, CentOS, Fedora.
1. Grammar
mysql [options] db
2. Parameter list
option
description
- ?| --help
display help information
--auto-rehash
Activate automatic rehash function
--bind-address = ip
Binding ip, when the computer has multiple network cards, you can specify the network card when mysql is connected
--character-sets-dir = path
Specifies the directory in which the character set resides
--column-names
Show column names in results
-C | --comments
Show comments in status sent to server
-c | --compress
Data compression between server and client
-D db | --database = db
specify the database name
--default-character-set = chatset
Default character set
-e statement | --execute = statement
Specify the command to use
-f | --force
enforcement
-H | --html
Output html format
-i | --ignore-spaces
Ignore spaces
--line-numbers
Display line numbers for error messages
--local-infile=0|1
Turn OFF or ON LOAD DATA INFILE
-A | --no-autp-rehash
Turn off automatic rehash
-b | --no-beep
Close Error Alert
-p password | --password =
Password used to connect to database
-W | --pipe
Connect databases using named pipes
-P port | --port =
Port used to connect to database
-- protocol = TCP|SOCKET|PIPI|MEMORY
Protocol used to connect to database
-q | --quick
Do not cache query results
-s | --silent
Output short content
-v | --verbose
Show detailed execution process
-V | --version
output version information
-w | --wait
latency
-X | --xml
Generate xml output
-u user | --user =
User name of the connection database, default is rootq
3. Examples
1) Log in
[root@localhost ~]# mysql -u root -p //connect database using user root
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.1.71 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> quit //quit
Bye
2) View permissions
mysql> show privileges;
+-------------------------+---------------------------------------+-------------------------------------------------------+
| Privilege | Context | Comment |
+-------------------------+---------------------------------------+-------------------------------------------------------+
| Alter | Tables | To alter the table |
| Alter routine | Functions,Procedures | To alter or drop stored functions/procedures |
| Create | Databases,Tables,Indexes | To create new databases and tables |
| Create routine | Databases | To use CREATE FUNCTION/PROCEDURE |
| Create temporary tables | Databases | To use CREATE TEMPORARY TABLE |
| Create view | Tables | To create new views |
| Create user | Server Admin | To create new users |
| Delete | Tables | To delete existing rows |
| Drop | Databases,Tables | To drop databases, tables, and views |
| Event | Server Admin | To create, alter, drop and execute events |
| Execute | Functions,Procedures | To execute stored routines |
| File | File access on server | To read and write files on the server |
| Grant option | Databases,Tables,Functions,Procedures | To give to other users those privileges you possess |
| Index | Tables | To create or drop indexes |
| Insert | Tables | To insert data into tables |
| Lock tables | Databases | To use LOCK TABLES (together with SELECT privilege) |
| Process | Server Admin | To view the plain text of currently executing queries |
| References | Databases,Tables | To have references on tables |
| Reload | Server Admin | To reload or refresh tables, logs and privileges |
| Replication client | Server Admin | To ask where the slave or master servers are |
| Replication slave | Server Admin | To read binary log events from the master |
| Select | Tables | To retrieve rows from table |
| Show databases | Server Admin | To see all databases with SHOW DATABASES |
| Show view | Tables | To see views with SHOW CREATE VIEW |
| Shutdown | Server Admin | To shut down the server |
| Super | Server Admin | To use KILL thread, SET GLOBAL, CHANGE MASTER, etc. |
| Trigger | Tables | To use triggers |
| Update | Tables | To update existing rows |
| Usage | Server Admin | No privileges - allow connect only |
+-------------------------+---------------------------------------+-------------------------------------------------------+
29 rows in set (0.00 sec)
Made a Linux learning platform, currently out of a prototype, you can refer to the use
Link: https://pan.baidu.com/s/1GOLVU2CbpBNGtunztVpaCQ Password:n7bk