码迷,mamicode.com
首页 > 数据库 > 详细

MySQL

时间:2015-10-26 22:07:37      阅读:210      评论:0      收藏:0      [点我收藏+]

标签:

建立数据库,建立用户,建表

显示数据库
show databases;

创建数据库
create database db_name;

删除数据库
drop database db_name;
或者
drop database if exists db_name;

使用某个数据库
use db_name;

创建用户并授权
create user user_name@localhost identified by ‘password‘;
grant all privileges on db_name.* to user_name@localhost;
实例:
create user tufujie@localhost identified by ‘123456‘;
grant all privileges on db_name.* to tufujie@localhost;

删除账户及权限:
delete from user where user=‘user_name‘ and host=‘localhost‘;
drop user user_name@‘%‘;
drop user user_name@localhost;

修改指定用户密码
update mysql.user set password=password(‘new_password‘) where user="user_name" and host="localhost";

显示当前数据库中所有的表
show tables;

MySQL

标签:

原文地址:http://www.cnblogs.com/tufujie/p/4912289.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!