zoukankan      html  css  js  c++  java
  • 2.MySQL入门基本操作初体验

    • 启动和关闭mysql服务器:

    一、启动方式

    1、使用 mysqld 脚本启动:/etc/inint.d/mysqld start

    2、使用 守护进程safe_mysqld 启动:safe_mysqld&

    二、停止

    1、使用 mysqld 脚本启动:/etc/inint.d/mysqld stop

    2、mysqladmin -u root -p shutdown

    三、重启

    使用 mysqld  脚本启动:/etc/inint.d/mysqld restart

    mysql_safe mysqladmin均/usr/bin目录下
    • 登录mysql服务器,通过在终端输入
    mysql -u root -p

    登录成功后会出现类似以下界面:

    mysql: [Warning] Using a password on the command line interface can be insecure.
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 8
    Server version: 5.7.16-0ubuntu0.16.04.1 (Ubuntu)
    
    Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    mysql> 
    1. 查看数据库:
      mysql> show databases;
      +--------------------+
      | Database           |
      +--------------------+
      | information_schema |
      | blpcd              |
      | foo                |
      | mysql              |
      | performance_schema |
      | sys                |
      +--------------------+
      6 rows in set (0.13 sec)
    2. 查看存储引擎:
      mysql> show engines;
      +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
      | Engine             | Support | Comment                                                        | Transactions | XA   | Savepoints |
      +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
      | MRG_MYISAM         | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
      | CSV                | YES     | CSV storage engine                                             | NO           | NO   | NO         |
      | InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |
      | BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |
      | MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |
      | PERFORMANCE_SCHEMA | YES     | Performance Schema                                             | NO           | NO   | NO         |
      | ARCHIVE            | YES     | Archive storage engine                                         | NO           | NO   | NO         |
      | MyISAM             | YES     | MyISAM storage engine                                          | NO           | NO   | NO         |
      | FEDERATED          | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |
      +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
      9 rows in set (0.03 sec)
    3. 查看数据表:
      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                        |
      | engine_cost               |
      | event                     |
      | func                      |
      | general_log               |
      | gtid_executed             |
      | help_category             |
      | help_keyword              |
      | help_relation             |
      | help_topic                |
      | innodb_index_stats        |
      | innodb_table_stats        |
      | ndb_binlog_index          |
      | plugin                    |
      | proc                      |
      | procs_priv                |
      | proxies_priv              |
      | server_cost               |
      | servers                   |
      | slave_master_info         |
      | slave_relay_log_info      |
      | slave_worker_info         |
      | slow_log                  |
      | tables_priv               |
      | time_zone                 |
      | time_zone_leap_second     |
      | time_zone_name            |
      | time_zone_transition      |
      | time_zone_transition_type |
      | user                      |
      +---------------------------+
      31 rows in set (0.00 sec)

      查看表时应先指定查看的数据库,正如上面的use mysql。

    4. 查看当前用户
      mysql> select user();
    5. 通过输入
      mysql> exit 或 mysql> q

      退出。

  • 相关阅读:
    闭包函数+装饰器(第十一天)
    函数初接触2
    函数初接触
    第八天
    第八天
    第七天
    day4—day6作业(补发)
    第六天
    第五天
    python基础学习-常用模块的使用(扩展补充,高级使用)(三)
  • 原文地址:https://www.cnblogs.com/jiandahao/p/6114063.html
Copyright © 2011-2022 走看看