1.新建数据库
mysql> create database testDB default character set utf8;
2.创建用户
mysql> GRANT USAGE ON *.* TO 'test123'@'%' IDENTIFIED BY 'test123' WITH GRANT OPTION;
注意:此处的'%',是指该用户可以远程登录,如果想本地登录的话,将"%"改为"localhost"。也可以指定某台机器可以远程登录。
3.用户授权
3.1 授权test用户拥有testDB数据库的所有权限
mysql> GRANT ALL PRIVILEGES ON testDB.* TO 'test123'@'%' IDENTIFIED BY 'test123';
3.2 授权部分权限
mysql>grant select,update on testDB.* to ‘test123’@‘%’ identified by 'test123'; mysql>flush privileges;
4. 删除用户和数据库
mysql>Delete FROM user Where User='test123' and Host='%'; mysql>flush privileges; mysql>drop database testDB;
5.设置表名不区分大小写
vi /usr/local/mysql/my.cnf #在mysql节点下加 lower_case_table_names=1