---
title: "Mysql建立用户"
author: "DoubleEO"
date: "2010-04-08T23:00:44Z"
tags: []
categories: ["数据库"]
slug: "mysql"
draft: false
lastmod: "2010-04-08T23:00:44Z"
id: 638481
url: "https://doubleeo.iteye.com/blog/638481"
---

登录mysql以后
mysql>use mysql;
mysql>desc user;
会看到很多属性，咱们只关注host user password
现在想建立新用户，可以用下面的语句
mysql> insert into mysql.user(Host,User,Password) values("localhost","doubleeo",password("123456"));
这样做以前是没问题的，但是现在再5.0以后，会出现ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value的错误。
所以，要用别的方式，先只创建用户名：
mysql>create user doubleeo;
然后使用GRANT语句进行授权，语句如下：
GRANT USAGE ON *.* TO 'doubleeo'@'localhost' IDENTIFIED BY '123456' WITH GRANT OPTION;
这样就不会报错了
其中*.*代表mysql的全局权限--global