MySQL Client server-side command summary

Source: Internet
Author: User
Tags mysql login

MySQL has the [client] and [mysqld] sections in the configuration file, and MySQL has its own client commands and server-side commands, which are described below briefly.

① if the administrator set a login password for the MySQL login but do not want to enter it every time you log in, you can create a hidden file under the login user's home directory, the file name is. MY.CNF, the following is the root user example:

Vi/root/./my.cnf

[Client]

user = root

Password = Redhat

host = localhost

After saving the exit, MySQL will automatically read the configuration file the next time you log in, so you can log in without having to enter your username password each time.

② You can specify what the default database will be after logging in before logging in:

Mysql–d MySQL//Set the default database after login is MySQL database.

Log in to see if you are in the MySQL database

SELECT DATABASE ();

③ written data script files can be directly imported into the database, there are two methods, one is direct input redirect in, the other is to use the client command to import data

Create a database script first

vi/root/mysql.sh

CREATE DATABASE HELLO;

Use HELLO

CREATE TABLE STU (ID int,name VARCHAR (30));

INSERT into STU (id,name) VALUES (' 1 ', ' MYSQL ');

MySQL </root/mysql.sh//Data import successfully, can go to view------à input redirection method

Mysql>

source/root/mysql.sh

. \/root/mysql.sh

④ Client Command Description:

Mysql>

\c: When not used before the input command terminator, the entry command is terminated prematurely and the command is not executed.

\d: Sets the command terminator, in MySQL, the default number of command Terminator semicolon.

\G: Executes the command regardless of the command terminator.

\g: No matter what the command terminator is, the command is executed and the results are displayed in a vertical form (looks intuitive).

\q: Exiting MySQL

\!shell command: Execute shell commands in MySQL \! Ll/root//View the asking price information under root.

⑤ Server-side commands

mysqladmin–uroot–h localhost password ' redhat '//password option to change the user password.

Mysqladmin Version//view MySQL run status and version information.

Mysqladmin status//view MySQL running status.

Mysqladmin extend-status//View status variable information.

Mysqladmin variables//view server variables.

Mysqladmin flush-privileges//Let mysqld re-read the authorization form = = = = Mysqladminreload

Mysqladmin Flush-status//Resets most server state variables.

Mysqladmin processlist//View the list of processes in progress.

Mysqladmin Refresh//reset host information as well as scroll relay and two-level log information. = = = Mysqladmin Flush-logs + mysqladmin flush-hosts.

Mysqladmin Start-slave//Starts the replication thread from the server.

Mysqladmin Stop-slave//stop copying threads.

PS: Server variables are divided into two categories, namely, global variables, and a class of session variables. After the global variable is defined, it takes effect immediately and is used with all sessions. Session variables are valid only for the current session.

View MySQL's global variables

Mysql>

Show global variables;

Mysql>

Show session variables//or show variables

In the process of invoking a server variable

Select @@ Global.sql_mode

SELECT @ @sql_mode

Set global sql_mode= "Strict_all_tables"

Set session sql_mode= "Strict_all_tables"

⑥ View property information for a table

Show Talbes status like ' user ' here like can use fuzzy matching.

Just write it down first. The back continue ....... .......

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

MySQL Client server-side command summary

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.