Linux 对mysql远程授权连接操作 和 查看mysql数据库和表 基本命令

Linux 对mysql远程连接的授权操作

首先linux连接mysql数据库

授权:
grant all on *.* to 'root'@'%' identified by '123456' with grant option;
//允许账户root从任何主机连接到所有数据库(*.*)
grant all on test.* to 'user'@'%' identified by '123456' with grant option;
//允许账户user从任何主机连接到test数据库(test.*)

释放远程授权:
revoke all on *.* from 'user'@'%';
//禁止用户user从任何主机访问所有数据库
revoke all on test.* from 'user'@'%';
//禁止用户user从任何主机访问test数据库
  
flush privileges;    //刷新系统授权表

连接不上关闭防火墙

关闭防火墙命令:systemctl stop firewalld.service

开启防火墙:systemctl start firewalld.service

关闭开机自启动:systemctl disable firewalld.service

开启开机启动:systemctl enable firewalld.service

linux连接mysql数据库对数据库的操作的一些基本命令

/usr/local/mysql/bin/mysql -uroot -p             //连接mysql数据库
 
mysql其他命令:

show databases; //显示数据库

create database name; //创建数据库 

use databasename; //选择数据库

drop database name //直接删除数据库,不提醒

show tables; //显示表 

describe tablename; //显示具体的表结构

select 中加上distinct去除重复字段

mysqladmin drop databasename //删除数据库前,有提示。

//显示当前mysql版本和当前日期

select version(),current_date;   

原创参考连接:https://www.cnblogs.com/cnteam/p/4091468.html

原文地址:https://www.cnblogs.com/boris-et/p/8317076.html