2014-09-10 123 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鏈接。