2014-09-10 112 views
-1

嗨我想玩弄MySQL数据库,我不知道我应该如何去创建一个数据库或表。我在网上冲浪了1个小时,特别是堆栈溢出,并尝试了几个解决方案,但最终只得到了低于错误的结果。我也忘了密码。请帮助访问被拒绝访问MySQL数据库的错误

无法使用命令create user'user1'@'localhost'创建新数据库;

Welcome to the MySQL monitor. Commands end with ; or \g. 
Your MySQL connection id is 4 
Server version: 5.6.19 MySQL Community Server (GPL) 

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. 

Oracle is a registered trademark of Oracle Corporation and/or its 
affiliates. Other names may be trademarks of their respective 
owners. 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 

mysql> show databases; 
+--------------------+ 
| Database   | 
+--------------------+ 
| information_schema | 
| test    | 
+--------------------+ 
2 rows in set (0.00 sec) 

mysql> CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password'; 
ERROR 1227 (42000): Access denied; you need (at least one of) the CREATE USER pr 
ivilege(s) for this operation 
mysql> 
mysql> create user 'user1'@'localhost'; 
ERROR 1227 (42000): Access denied; you need (at least one of) the CREATE USER privilege(s) for this operation 
mysql> 

回答

2
  1. 您需要选择要首先在其DB你想使用命令使用这样USE test;瓶坯变化。

  2. 为了创建一个数据库使用以下语法CREATE DATABASE dbName;

  3. 创建表的语法是这样的CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20), species VARCHAR(20), sex CHAR(1), birth DATE, death DATE);(从MySQL单证拍摄)

  4. 我不知道哪个用户连接你到MySQL数据库但如果您没有任何权限创建新用户并授予新用户相应的权限

0

由于你忘了密码,你必须恢复它。 事实上,你很有可能可以用“root”帐户访问它,而不需要密码。

据“MySQL参考”:

“如果你从来没有设置MySQL的root密码,服务器不 需要密码在所有的连接为根”

无论如何,请阅读this链接。