Required for O & M-Common Operations (queries are provided for friends and will be updated continuously)

Source: Internet
Author: User
Tags bit set
Micro Blog: http://xsboke.blog.51cto.com

Xiaosheng Q: 1770058260

------- Thank you for your reference. If you have any questions, please contact us.
  1. MySQL
# Mysql Data Import and Export # The queried data is exported to the CSV file select * from user where username = 'xiaoliinto outfile'/tmp/user.csv 'fields terminated ', 'optionally enclosed by '"'Lines terminated by' \ n ';
# Import the CSV file to the load data infile '/user.csv' into Table userfields terminated by ', 'optionally enclosed by' "'Lines terminated by '\ n '; # When creating a MySQL database, specify the character set create database 'dbname' default Character Set utf8 collate utf8_general_ci; # It is recommended that a database master-slave role SWAp process database master-slave role swap: https://www.cnblogs.com/nbuntu/p/5523331.html? master to master_host = 'master _ ip', master_user = 'app _ user', master_password = 'app _ pas Swd', master_port = 3306, master_log_file = 'mariadb-bin.000003 ', master_log_pos = 4; # query the database size # enter the information_schema database (storing information about other databases) Use information_schema; # query the size of all data: Select Concat (round (sum (data_length/1024/1024), 2), 'mb') as data from tables; # view the size of the specified database: # For example, view the Database Home size select Concat (round (sum (data_length/1024/1024), 2), 'mb') as data from tables where table_schema = 'home '; # viewing the size of a table in a specified database # For example, viewing membe in the Database Home Select Concat (round (sum (data_length/1024/1024), 2), 'mb') as data from tables where table_schema = 'Home' and table_name = 'members '; # MySQL repair table check table and repair table log on to the MySQL terminal: mysql-uxxxxx-P dbname check table tabtest; If the status is OK, no repair is required. If there is an error, you can use: repair table tabtest; To fix the vulnerability. After the fix, you can run the check table command to check the vulnerability. You can also use the check/repair function in the new phpMyAdmin version. # Error in master-slave replication: InnoDB: cocould not find a valid tablespace file for 'dbname/tbname '. the solution is generally for a table with partitions. In this case, alter table tbname add partition (partition p20180907 values in (737309 ));
  1. Redis batch deletion through fuzzy query key
redis-cli -h 192.168.0.1 -p 6379  keys "*lottery-method-max-prize*" | xargs redis-cli -h 192.168.0.1 -p 6379 del
  1. Zip compression to Exclude directories or files
zip -r yasuo.zip /var/www -x="/var/www/logs/*"
  1. Application of lsof
Lsof-c mysql: view files opened by a process
  1. Nginx
# Nginx directly returns text to the page location/remote_addr {default_type text/plain; return 200 "$ remote_addr \ n" ;}# HTTPS jump if ($ scheme = http) {return 301 https: // $ host $ request_uri ;}
  1. Disk unit conversion
Disk unit conversion 1 TB = 1024gb1gb = 1024mb1mb = 1024kb1kb = 1024 byte
  1. Shell
# $ Shell PID (processid) $! PID of the background process last run by Shell $? End code of the last command (Return Value) $-flag list set using the set command $ * List of all parameters. For example, when "$ *" is included in... $ N "to output all parameters. [Email protected] list of all parameters. For example, when "[email protected]" is enclosed "... All parameters are output in the form of "$ N. $ # Number of parameters added to shell $0 name of the shell itself $1 ~ $ N parameter values added to shell. $1 is the 1st parameter, and $2 is the 2nd parameter .... # Color/033 [31 m text/033 [0m31 Red 32 green 33 ×××34 blue # If condition judgment 1. Basic Syntax: If [command]; then: The statement fi2 that meets the condition. Extended Syntax: If [command]; then: the statement Elif [command] that meets the condition. the else statement that the then statement meets the condition is fi3. syntax description: bash shell executes the if statement in sequence. If the command is executed and its return status is 0, the statement that meets this condition will be executed. Otherwise, the subsequent command will not be executed and will jump to the next command. When multiple nesting statements exist, only the first command that returns the 0 exit state will execute the statement that meets the condition. If the execution status of all statements is not 0, then execute the statement in else. Return status: the exit status of the last command, or 0 if no conditions are true. Note: 1. [] indicates a condition test. Note that spaces are important. Note that there must be spaces before '[' and ']'. 2. In Shell, then and Fi are separate statements. If you want to enter data in the same line, separate them with semicolons. 3. Pay attention to the processing of variables in If judgment. quotation marks are required to avoid unnecessary errors. If no double quotation marks are added, some string variables containing spaces are judged incorrectly. For example, if the value of [-n "$ Var"] is null, an error occurs. 4. It is determined that the floating point value is not supported. 5, the system will think it is an output or input redirection. Although the result is displayed correctly, it is actually incorrect. Therefore, we need to convert these symbols. 6. In the default, the error message generated by running the command in the IF statement still appears in the output result of the script. 7. Use-Z or-N to check the length, undefined variables are also 08, empty variables, and uninitialized variables may have a catastrophic impact on shell script testing. Therefore, when you are not sure about the variable content, run-N or-Z before the test number to test 9 ,? The variable contains the exit status of the previously executed command (the last completed foreground process) (which can be used to detect the exit status) file/directory judgment: [-a file] If the file exists, it is true. [-B file] If the file exists and is a block file, the return value is true. [-C file] If the file exists and is a character file, the return value is true. [-D file] If the file exists and is a directory, the return value is true. [-E file] returns true if the specified file or directory exists. [-F file] If the file exists and is a common file, the return value is true. [-G file] If the file exists and the sgid is set, the return value is true. [-H file] If the file exists and is a symbolic link file, the return value is true. (This option is invalid in some old systems) [-K file] returns true if the file exists and has an adventure bit set. [-P file] returns true if the file is stored in a command pipeline. [-R file] If the file exists and is readable, the return value is true. [-S file] If the file exists and the size is not 0, the return value is true. [-U file] If the file exists and the SUID bit is set, the return value is true. [-W file] If the file exists and is writable, the return value is true. (A directory must be executable for its content access.) [-X file] If the file exists and is executable, the return value is true. [-O file] returns true if the file exists and belongs to a valid user ID. [-G file] If file exists and the default group is the current group, true is returned. (Only check the default system group) [-l file] If the file exists and is a symbolic connection, the return value is true. [-N file] If the file exists and has been mod, if IED since it was last read, true is returned. [-S file] If the file exists and is a socket, the return value is true. [File1-nt file2] returns true if file1 is newer than file2, or if file1 exists but file2 does not exist. [File1-ot file2] If file1 is older than file2, or file2 exists but file1 does not exist, true is returned. [File1-Ef file2] If file1 and file2 point to the same device and node number, true is returned. String judgment [-Z string] returns true if the string length is zero, that is, null is true. [-N string] returns true if the string length is not zero, that is, if the value is not null, it is true [string1]. If the value of the string is not null, return true. If the value is-N, it is similar to [string1 = string2]. If the two strings are the same, return true [string1! = String2] returns true if the strings are different [string1 <string2] If the "string1" dictionary is sorted before "string2", returns true. [String1> string2] returns true if the "string1" dictionary is sorted after "string2.
  1. Git
Manually update git branch 'date + % Y % m % d % H % m % s' # Back up git pull # Pull git branch # view the branch rollback to switch to the old branch git Branch the old branch git checkout [branch name] git checkout mastergit checkout. # discard all current operations
  1. Ubuntu
# Disable Ubuntu to automatically download the latest Kernel configuration and modify the configuration file/etc/APT/apt. conf. d/10 periodic. Change "1" to "0" and save it. 0 is to disable VI/etc/APT/apt. conf. d/10 periodic apt: periodic: Update-package-Lists "0"; apt: periodic: Download-upgradeable-packages "0"; apt: periodic :: autocleaninterval "0"; # create a user, by default, UBUNTU does not automatically create the Home Directory useradd-S/bin/bash-G Sudo-k/etc/skel-m-D/home/username Username

Required for O & M-Common Operations (queries are provided for friends and will be updated continuously)

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.