北极星光 发表于 2018-10-5 11:33:22

mysql更改root密码,连接mysql,常用操作

mysql> show databases;  +--------------------+
  | Database         |
  +--------------------+
  | information_schema |
  | mysql            |
  | performance_schema |
  | test               |
  +--------------------+
  4 rows in set (0.00 sec)
  mysql> use mysql;
  Reading table information for completion of table and column names
  You can turn off this feature to get a quicker startup with -A
  Database changed
  mysql> show tables;
  +---------------------------+
  | Tables_in_mysql         |
  +---------------------------+
  | columns_priv            |
  | db                        |
  | event                     |
  | func                      |
  | time_zone               |
  | time_zone_leap_second   |
  +---------------------------+
  28 rows in set (0.00 sec)
  mysql> desc time_zone;
  +------------------+------------------+------+-----+---------+----------------+
  | Field            | Type             | Null | Key | Default | Extra          |
  +------------------+------------------+------+-----+---------+----------------+
  | Time_zone_id   | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
  | Use_leap_seconds | enum('Y','N')    | NO   |   | N       |                |
  +------------------+------------------+------+-----+---------+----------------+
  2 rows in set (0.11 sec)
  mysql> show create table time_zone\G;
  #G=grep筛选文字内容,规律显示出来
  *************************** 1. row ***************************
  Table: time_zone
  Create Table: CREATE TABLE `time_zone` (
  `Time_zone_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Use_leap_seconds` enum('Y','N') NOT NULL DEFAULT 'N',
  PRIMARY KEY (`Time_zone_id`)
  ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Time zones'
  1 row in set (0.03 sec)
  ERROR:
  No query specified
  mysql> select user();
  +----------------+
  | user()         |
  +----------------+
  | root@localhost |
  +----------------+
  1 row in set (0.07 sec)
  mysql> select database();
  +------------+
  | database() |
  +------------+
  | mysql      |
  +------------+
  1 row in set (0.00 sec)
  mysql> select * from user\G;
  创建库:
  mysql> create database db1;
  Query OK, 1 row affected (0.02 sec)
  创建表:
  mysql> use db1;
  #先切换到指定库下
  Database changed
  mysql> create table t1(`id` int(4),`name` char(40)) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  #括号中是定义字段及字段格式,使用反引号引起来
  Query OK, 0 rows affected (1.51 sec)
  mysql> select version();
  +-----------+
  | version() |
  +-----------+
  | 5.6.35    |
  +-----------+
  1 row in set (0.06 sec)
  mysql> show status;
  +-----------------------------------------------+-------------+
  | Variable_name                                 | Value       |
  +-----------------------------------------------+-------------+
  | Aborted_clients                               | 0         |
  | Aborted_connects                              | 0         |
  +-----------------------------------------------+-------------+
  mysql> show variables\G;
  mysql> show variables like 'max_connect%'\G;
  #like表示匹配;%是通配符
  更改参数:
  mysql> set global max_connect_errors=110;
  Query OK, 0 rows affected (0.04 sec)
  #在此只是临时更改,如果要永久更改,需要编辑配置文件
  查看队列:
  mysql> show processlist;
  +----+------+-----------+------+---------+------+-------+------------------+

  |>  +----+------+-----------+------+---------+------+-------+------------------+
  |5 | root | localhost | db1| Query   |    0 | init| show processlist |
  +----+------+-----------+------+---------+------+-------+------------------+
  1 row in set (0.01 sec)
  mysql> drop table t1;
  Query OK, 0 rows affected (0.32 sec)
  mysql> drop database db1;
  Query OK, 0 rows affected (0.10 sec)

页: [1]
查看完整版本: mysql更改root密码,连接mysql,常用操作