0

現在、独学でMySQLの勉強をしてます。(pythonをメインで勉強しており、MySQLのテーマを扱ってます)
MySQLの環境構築を行った後、データベースとテーブル作成というプロセスでエラーが出たため、解消方法をご教授いただきたいです。
※詳細のステップ3[3つ目]の箇所に記載

■実行したこと
ステップ1 MySQL serverのインストール
ステップ2 MySQL Database Driverをpython環境へインストール
ステップ3 データベースとテーブルの作成(ここで躓いてます)

■詳細(実行したこと)
ステップ2

(base) sugimotoyuuki@sugimotoyuukinoMacBook-Air-2 webapp % sudo -H python3 setup.py install
Password:
running install
running bdist_egg
running egg_info
writing vsearch.egg-info/PKG-INFO
writing dependency_links to vsearch.egg-info/dependency_links.txt
writing top-level names to vsearch.egg-info/top_level.txt
reading manifest file 'vsearch.egg-info/SOURCES.txt'
writing manifest file 'vsearch.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.9-x86_64/egg
running install_lib
running build_py
creating build/bdist.macosx-10.9-x86_64/egg
copying build/lib/vsearch.py -> build/bdist.macosx-10.9-x86_64/egg
byte-compiling build/bdist.macosx-10.9-x86_64/egg/vsearch.py to vsearch.cpython-37.pyc
creating build/bdist.macosx-10.9-x86_64/egg/EGG-INFO
copying vsearch.egg-info/PKG-INFO -> build/bdist.macosx-10.9-x86_64/egg/EGG-INFO
copying vsearch.egg-info/SOURCES.txt -> build/bdist.macosx-10.9-x86_64/egg/EGG-INFO
copying vsearch.egg-info/dependency_links.txt -> build/bdist.macosx-10.9-x86_64/egg/EGG-INFO
copying vsearch.egg-info/top_level.txt -> build/bdist.macosx-10.9-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating 'dist/vsearch-1.0-py3.7.egg' and adding 'build/bdist.macosx-10.9-x86_64/egg' to it
removing 'build/bdist.macosx-10.9-x86_64/egg' (and everything under it)
Processing vsearch-1.0-py3.7.egg
Removing /Users/sugimotoyuuki/opt/anaconda3/lib/python3.7/site-packages/vsearch-1.0-py3.7.egg
Copying vsearch-1.0-py3.7.egg to /Users/sugimotoyuuki/opt/anaconda3/lib/python3.7/site-packages
vsearch 1.0 is already the active version in easy-install.pth

Installed /Users/sugimotoyuuki/opt/anaconda3/lib/python3.7/site-packages/vsearch-1.0-py3.7.egg
Processing dependencies for vsearch==1.0
Finished processing dependencies for vsearch==1.0

ステップ3
ターミナルで以下を実行
[1つ目]

(base) sugimotoyuuki@sugimotoyuukinoMacBook-Air-2 webapp % mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.22 MySQL Community Server - GPL

Copyright (c) 2000, 2020, 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.

[2つ目]
※一度作成後、二度目の実行のため、以下のようになってます。

mysql> create database vsearchlogDB;
ERROR 1007 (HY000): Can't create database 'vsearchlogDB'; database exists

[3つ目]
※ここで躓いてます Query Okのような文言が本来出るとテキスト(Head first python page287に書いてます)

mysql> grant all on vsearchlogDB.* to 'vsearch' identified by 'vsearchpasswd';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by 'vsearchpasswd'' at line 1

画像の説明をここに入力

5
  • まぁ、少なくとも identidiedidentified でしょうね。。。
    – user39889
    2021年1月11日 13:37
  • pythonとの関係がわかりませんでした。無関係ですかね?
    – sayuri
    2021年1月12日 0:53
  • 皆様 編集、ご回答ありがとうございます。 おっしゃる通り、pythonには無関係な案件のため タグをmysqlに変更させていただきました。 また、identifiedに変えて再度実行しましたが同じエラーが出てしまっております。 2021年1月12日 2:50
  • 3
    MySQL 8以降はGRANTによるユーザ作成ができないできず、あらかじめCREATE USERでユーザを作成しておく必要があるようです。
    – payaneco
    2021年1月12日 4:47
  • 1
    ありがとうございます。 こちらの情報をもとに、調べてみたところ、head first python 3rd の正誤表 oreilly.com/catalog/errata.csp?isbn=0636920036777 にMYSQL8以降のコードが有志により記載されてました。 create user 'vsearch' identified by 'vsearchpasswd'; を実行した後、 grant all on vsearchlogDB.* to 'vsearch'; を実行したところエラーなく進めました。 皆様ご教授いただきありがとうございました。 2021年1月12日 10:55

0

この質問に回答するには、ログインする必要があります。

のタグが付いた他の質問を参照する。