Environment variables for MySQL
- Server variables: Adjust MySQL's working properties, determined by the MySQL configuration file
- State variables: Self-statistics that are output after MySQL runs
View MySQL's environment variables under Linux
1. Get MySQL client Help
#/usr/local/mysql/bin/mysql–help–v (in the Help message--is the MySQL client command, not--is the MySQL server variable)
Reading order of 2.MySQL configuration files
/etc/my.cnf >/etc/mysql/my.cnf >/usr/local/mysql/etc/my.cnf (Find configuration files in this order)
Note: The end result is a collection of all profiles, the same option is valid at the last read
To view the global variables for MySQL:
To view the environment variables currently connected to MySQL:
User management for MySQL
Tip: View user passwords in MySQL
1. Create a user
GRANT all on * * to ' localhost '; (anonymous user created)
2. Change user password
UPDATE mysql.user SET password= ' where user= ' root ' and host= ' localhost ';
3. Delete a user
Mode one: DELETE from Mysql.user WHERE password= ' and user= ' root ';
Mode two: DROP user @ Host
Wildcard characters for Ps:mysql
%: All Users
_: Any character of a unit length (note a unit length)
Set User settings password
1. Set a password for the user individually
Format:
SET PASSWORD for ' UserName ' @ ' HostName ' = PASSWORD (' Newpss ')
2. Batch modify passwords for multiple users
Format:
UPDATE mysql.user SET password= ' newpass ' WHERE condition
3. Using a MySQL client tool-mysqladmin
Format:
Mysqladmin-u User-P old password Password new password-h host
Note: The host here refers to the user can use this password to log on to the host on the MySQL
MySQL client and server-side communication
1, local communication: MySQL client and server side on the same host, and to be based on the LO interface or 127.0.0.1 communication.
Linux System (Unix sock)
compile installation:/tmp/ Mysql.sock
RPM Installation:/var/lib/mmysql/ Mysql.sock
Windows
memory
Pipe
2, remote communication: MySQL client and server side on the same host, but the communication is based on IP communication , or the client and server side are not on the same host.
Socket:ip+port
Common clients
mysql
mysqladmin
Common options for Mydqldump
mysqlcheck
Client Tools
-u--user=
-H--host=
-P--password=
- -port=
--protocol={socket|memory|pipe}
--socket=
MySQL
two modes of operation
1, interactive mode
MySQL >
2, Batch mode
# mysql-u root-p123 < ; 1.sql
Commands available in interactive mode
server-side commands:
access: Help COMMAND;
Client commands:
\h
\c
\g
\g
\q
\s
\!
\#
Queries the keywords available to MYQL clients:
Help contents;
MySQL Client-only options
-C or-compress: Compressed transport
--DEFAULT-CHARACTER-SET=NAME Specifies the type of character set used by the MySQL client.
-E,--execute=name: Execute mysql command in bash
-H or--html: output results as Web pages
The MySQL prompt
MySQL >
Line-continuation character
/*> annotation Characters
' >
MySQL operation log
~/.mysql_history
MySQL shortcut keys
Ctrl+w: One word before each deletion of the cursor
Ctrl+u: Delete all before the cursor
Ctrl+y: Pasting
CTRL + A: Cursor moves to the beginning of the line
Ctrl+e: Cursor moves to end of line
Environment variables for MySQL