---
title: "mysql 添加用户，并对数据库授权"
author: "haiker"
date: "2011-12-07T11:46:10Z"
tags: ["MySQL"]
categories: ["数据库"]
slug: "mysql"
draft: false
lastmod: "2011-12-07T11:46:10Z"
id: 1295330
url: "https://haiker.iteye.com/blog/1295330"
---

use mysql;

insert into user(host, user,password) values('%','myusername',password('myusername'));

create database \`mydatabase\`;

grant all privileges on \`mydatabase\`.* to myusername@'%';

delete from user where host='localhost' and user='myusername';

flush privileges;