zoukankan      html  css  js  c++  java
  • Mysql 8 常用命令测试

    1.创建数据库,帐号及授权

    create database testdb;

    CREATE USER 'rusking'@'%' IDENTIFIED BY '12345678';

    CREATE USER 'rusking'@'%' IDENTIFIED WITH mysql_native_password BY '12345678';
    GRANT ALL ON testdb.* TO 'rusking'@'%' WITH GRANT OPTION;

    flush privileges;

    2.登录Mysql:

    mysql -u db_user -pdb_password -h db_host db_name
    mysql -urusking -p12345678 -h loclahost testdb

    3.查看Mysql版本

    [root@www ~]# mysql -V
    mysql  Ver 8.0.15 for Linux on x86_64 (MySQL Community Server - GPL)
    [root@www ~]# mysql -uroot -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 20
    Server version: 8.0.15 MySQL Community Server - GPL
    
    Copyright (c) 2000, 2019, 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> select version();
    +-----------+
    | version() |
    +-----------+
    | 8.0.15    |
    +-----------+
    1 row in set (0.01 sec)
    
    mysql> status;
    --------------
    mysql  Ver 8.0.15 for Linux on x86_64 (MySQL Community Server - GPL)
    
    Connection id:          20
    Current database:
    Current user:           root@localhost
    SSL:                    Not in use
    Current pager:          stdout
    Using outfile:          ''
    Using delimiter:        ;
    Server version:         8.0.15 MySQL Community Server - GPL
    Protocol version:       10
    Connection:             Localhost via UNIX socket
    Server characterset:    utf8mb4
    Db     characterset:    utf8mb4
    Client characterset:    utf8mb4
    Conn.  characterset:    utf8mb4
    UNIX socket:            /var/lib/mysql/mysql.sock
    Uptime:                 1 hour 5 min 14 sec

    4. 查看及修改加密方式

    select user,plugin from user ;

    ALTER USER 'rusking'@'%' IDENTIFIED WITH mysql_native_password BY '12345678';

    5. 导入数据库:

    常用source 命令
    进入mysql数据库控制台,
    如mysql -u root -p
    mysql>use 数据库
    然后使用source命令,后面参数为脚本文件(如这里用到的.sql)
    mysql>source d:wcnc_db.sql

    6.其它命令

    show databases;--查看所有数据库

    use testdb;--切换到testdb数据库

    show tables;---查看当前库中的所有表

    select user(); --查看当前登录用户

    select database();--查看当前连接的数据库

    describe tablename; --查看表结构

     https://linuxize.com/post/how-to-create-mysql-user-accounts-and-grant-privileges/

    Mysql8用户角色管理

  • 相关阅读:
    java的反射机制浅谈 分类: java
    2.4.3 Cow Tours
    2.4.2 Overfencing
    2.4.1 The Tamworth Two
    Shortest Paths
    2.3.5 Controlling Companies
    2.3.4 Money Systems
    2.3.3 Zero Sum
    2.3.2 Cow Pedigrees
    2.3.1 Longest Prefix
  • 原文地址:https://www.cnblogs.com/rusking/p/10562484.html
Copyright © 2011-2022 走看看