mysql 创建用户,创建数据库

//创建用户并设置本地访问,禁止远程访问
# create user 'oppo'@'localhost' identified by 'oppo#O2018'; 
//创建用户并设置可以远程访问
# create user 'oppo'@'%' identified by 'oppo#O2018';
//刷新
# flush privileges;
//创建数据库
# create database oppo DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
//给数据库授权用户,远程可访问
# grant all privileges on `oppo`.* to 'oppo'@'%' identified by 'oppo#O2018';
 //给数据库授权用户,远程不可访问
# grant all privileges on `oppo`.* to 'oppo'@'localhost' identified by 'oppo#O2018';
//刷新
# flush privileges;
//if exists 判断数据库是否存在,不存在也不产生错误
drop database if exists drop_database;  

你可能感兴趣的:(mysql 创建用户,创建数据库)