mysql 创建与授权

set global read_only=0;
set global optimizer_switch='derived_merge=off'; 
create user 'my_user'@'%' identified by 'my_password';
create database my_db DEFAULT CHARSET 'utf8' COLLATE 'utf8_unicode_ci';   

只授权这个数据库
grant all privileges on my_db.* to 'my_user'@'%' identified by 'my_password';

授权root
grant all privileges on *.* to 'root'@'%' identified by '123456';

授权root 并附带可授权
grant all privileges on *.* to 'root'@'%' identified by '123456' WITH GRANT OPTION;

flush privileges;
如果遇到 ERROR 1709 (HY000): Index column size too large. The maximum column size is 767 bytes. 错误

  a)打开 my.ini 给 [mysqld] 增加如下配置:

innodb_large_prefix = ON
innodb_file_format = Barracuda
innodb_file_per_table = ON

  b)并修改报错的建表语句后面加上:ENGINE=InnoDB row_format=DYNAMIC;

# 若没有修改my.ini的权限也可以使用命令查看参数和设置参数:
show global variables like "innodb_large_prefix";
show global variables like "innodb_file_format";
show global variables like "innodb_file_per_table";
set global innodb_large_prefix=ON;
set global innodb_file_format=Barracuda;
set global innodb_file_per_table=ON;

如果遇到ERROR1709(HY000):Indexcolumnsizetoolarge.Themaximumcolumnsizeis767bytes.错误a)打开my.ini[mysqld]增加如下配置:innodb_large_prefix=ONinnodb_file_format=Barracudainnodb_file_per_table=ONb)并修改报错的建表语句后面加上:ENGINE=InnoDB row_format=DYNAMIC;# 若没有修改my.ini的权限也可以使用命令查看参数和设置参数: showglobalvariableslike"innodb_large_prefix"; showglobalvariableslike"innodb_file_format"; showglobalvariableslike"innodb_file_per_table"; setglobalinnodb_large_prefix=ON;setglobalinnodb_file_format=Barracuda;setglobalinnodb_file_per_table=ON;

原文地址:https://www.cnblogs.com/ilovecpp/p/12842285.html