MYSQL简介

1、varchar(15)    存放15个汉字        编码:utf8       mysql版本:5.6.36

2、utf8     1个汉字 = 3个字节      一个字母或数字 = 1个字节      一个字符 = 2个字节

3、查询一数据库数据总量

查询phpcms库中,所有表的总量

select sum(TABLE_ROWS) from (SELECT TABLE_NAME, TABLE_ROWS FROM `information_schema`.`tables`  WHERE `table_schema` = 'phpcms') as table1

查询phpcms库中,所有表,所含数据量

SELECT TABLE_NAME, TABLE_ROWS FROM `information_schema`.`tables`  WHERE `table_schema` = 'phpcms'

4、mysql权限设置

@查看所有数据库

  show databases;

@查看单当前数据库

  select databse();

@查看当前库的所有表

  show tables;

@创建用户

  create user 'test'@'localhost' identified  by 'test';

@分配权限

① 设置访问单个数据库权限

01.mysql>grant all privileges on test.* to 'root'@'%';(说明:设置用户名为root,密码为空,可访问数据库test)

②设置访问全部数据库权限

01.mysql>grant all privileges on *.* to 'root'@'%';(说明:设置用户名为root,密码为空,可访问所有数据库*)

③设置指定用户名访问权限

01.mysql>grant all privileges on *.* to 'seim'@'%';(说明:设置指定用户名为 seim,密码为空,可访问所有数据库*)

④设置密码访问权限

01.mysql>grant all privileges on *.* to 'seim'@'%' IDENTIFIED BY ' seim';(说明:设置指定用户名为 seim,密码为 seim,可访问所有数据库*)

⑤设置指定可访问主机权限

01.mysql>grant all privileges on *.* to ' seim'@'10.2.1.11';说明:设置指定用户名为 seim,可访问所有数据库*,只有127.0.0.1这台机器有权限访问
 

原文地址:https://www.cnblogs.com/Sophia-zly/p/8329806.html