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用户角色管理

转载于:https://www.cnblogs.com/rusking/p/10562484.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值