mysql--connections, common commands

Source: Internet
Author: User

Connection

mysql-uroot-p123456 #默认会使用sock端口登录

mysql-uroot-p123456-h127.0.0.1-p3306 #使用ip +3306-Port login, remote

Mysql-uroot-p123456-s/tmp/mysql.sock #使用监听的sock; suitable for this machine

Mysql-uroot-p123456-e "Show Databases" #使用在shell脚本里面

Common commands

One:

MySQL commands that are commonly used:

Query the library show databases; switch the library use MySQL; View the tables in the Library show tables; View the table's fields desc tb_name; View the build Table statement show create table tb_name\g; View Current User  s elect user (); View the database currently in use  select () ***************************************************************** DESC user;   View a table field with which show create table user\g;   Plus G is a relatively orderly, neat point; select * from User\g; Plus g, the effect is as follows; ***************************************************************** view MySQL command history: Ls-al     # You'll see a file for. mysql_historyless  .mysql_history**************************************************************** *use Mysql;select Database ()   #查看当前使用的数据库 ***************************************************************** II: CREATE database DB1; Create a table use Db1;create table T1 (' id ' int (4), ' name ' char (40)); View current database version select version (); View database status sh ow status; View parameters  show variables;show variables like ' max_connect% '; modify parameter set global max_connect_errors=1000; View queue Show Processlist;  show full processlist;   Creating library, create Database Db1;show Databases;uSe db1;create table t1 (' id ' int (4), ' name ' char (+)); Show create table T1\g;drop table T1; Delete this table create TABLE T1 (' id ' int (4) , ' name ' char (+)) Engine=innodb DEFAULT charset=utf8;show CREATE TABLE t1\g;   will see CharSet become Utf8;select version (); show status;show variables;show variables like ' max_connect% '; or view show Variable like ' sock% '; the set global max_connect_errors=1000;show variables like ' max_connect% '; This is changed to a value of 1000, and if a restart is required, You need to modify the my.cnf file; *****************************************************************show processlist; Show Full processlist;  #此命令令可以查看: 1. What are you doing with MySQL? 2. Which users are connected? 3. When the connection is done, there is no lock table;

mysql--connections, common commands

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.