Mysql常用命令

grant all privileges on *.* to ‘monitor’@’192.168.1.252’ identified by ‘cciechao’ with grant option;

查询连接数

select SUBSTRING_INDEX(host,’:’,1) as ip , count(*) from information_schema.processlist group by ip;

查看用户权限

show grants for ‘baobiao’@’172.18.100.239′;

Flush privileges;(更新权限)

导出数据和表结构:

mysqldump -u用户名 -p密码 数据库名 > 数据库名.sql

#/usr/local/mysql/bin/   mysqldump -uroot -p abc > abc.sql

敲回车后会提示输入密码

2、只导出表结构

mysqldump -u用户名 -p密码 -d 数据库名 > 数据库名.sql

#/usr/local/mysql/bin/   mysqldump -uroot -p -d abc > abc.sql

导入数据库

1、首先建空数据库

mysql>create database abc;

2、导入数据库

方法一:

(1)选择数据库

mysql>use abc;

(2)设置数据库编码

mysql>set names utf8;

(3)导入数据(注意sql文件的路径)

mysql>source /home/abc/abc.sql;

方法二:

mysql -u用户名 -p密码 数据库名 < 数据库名.sql

#mysql -uabc_f -p abc < abc.sql

查询数据库     查询表      查询表指定内容

Show databases;  show tables;  select * from tablename where name=name;

创建库         创建表      插入数据

Create database  create table   insert into tablename values ()

修改表内容

Update tablename set xx=yy where xx=yy;

删除数据库删除表 删除表内容

Drop database name   drop table name   delelte from tablename where xx=yy;

查看mysql连接数

select SUBSTRING_INDEX(host,’:’,1) as ip , count(*) from information_schema.processlist group by ip;

查看当前最大连接数

show variables like ‘max_connections’;

设置mysql最大连接数

set global max_connections=10;

原文地址:https://www.cnblogs.com/chaoe/p/7606657.html