前提・実現したいこと
hostのエラーを改善して、terminalでmysqlを実行できるようにしたい。
発生している問題・エラーメッセージ
,1ターミナル。 mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on '127.0.0.1:3306' (61 Connection refused) 2,いつもの画面 (base) SN:toudai SN$ sudo mysql.server start Password: Starting MySQL . ERROR! The server quit without updating PID file (/usr/local/var/mysql/SN.local.pid). (base) SN:toudai SN$ mysql -u root ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) (base) SN:toudai SN$
該当のソースコード
ターミナルの方です。 The default interactive shell is now zsh. To update your account to use zsh, please run `chsh -s /bin/zsh`. For more details, please visit https://support.apple.com/kb/HT208050. (base) SN:toudai SN$ ls data.py main.py mysite test_sqlite.db venv (base) SN:toudai SN$ (base) SN:toudai SN$ cd vnev bash: cd: vnev: No such file or directory (base) SN:toudai SN$ cd data.py bash: cd: data.py: Not a directory (base) SN:toudai SN$ (base) SN:toudai SN$ mysql -h X.X.X.X -P 3306 -u wordpress -p Enter password: ERROR 2005 (HY000): Unknown MySQL server host 'X.X.X.X' (0) (base) SN:toudai SN$ (base) SN:toudai SN$ show variables like 'port'; bash: show: command not found (base) SN:toudai SN$ (base) SN:toudai SN$ mysql -u root ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) (base) SN:toudai SN$ (base) SN:toudai SN$ sudo mysql.server start Password: Starting MySQL . ERROR! The server quit without updating PID file (/usr/local/var/mysql/SN.local.pid). (base) SN:toudai SN$ (base) SN:toudai SN$ mysql -u root ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) (base) SN:toudai SN$ (base) SN:toudai SN$ brew uninstall mysql Uninstalling /usr/local/Cellar/mysql/8.0.23... (298 files, 297.8MB) (base) SN:toudai SN$ brew install mysql Updating Homebrew... ==> Auto-updated Homebrew! Updated 3 taps (homebrew/core, homebrew/cask and mongodb/brew). ==> Updated Formulae Updated 19 formulae. ==> Updated Casks Updated 14 casks. ==> Downloading https://homebrew.bintray.com/bottles/mysql-8.0.23.big_sur.bottle.tar.gz Already downloaded: /Users/SN/Library/Caches/Homebrew/downloads/3fb6af4a674bc868f1e2234f3109496004ef05053a7b2a2ce278b2c0997bcbe5--mysql-8.0.23.big_sur.bottle.tar.gz ==> Pouring mysql-8.0.23.big_sur.bottle.tar.gz ==> Caveats We've installed your MySQL database without a root password. To secure it run: mysql_secure_installation MySQL is configured to only allow connections from localhost by default To connect run: mysql -uroot To have launchd start mysql now and restart at login: brew services start mysql Or, if you don't want/need a background service you can just run: mysql.server start ==> Summary ???? /usr/local/Cellar/mysql/8.0.23: 298 files, 297.8MB (base) SN:toudai SN$ (base) SN:toudai SN$ sudo mysql.server start Starting MySQL .. ERROR! The server quit without updating PID file (/usr/local/var/mysql/SN.local.pid). (base) SN:toudai SN$
import mysql.connector conn = mysql.connector.connect(host='127.0.0.1') cursor = conn.cursor() cursor.execute( 'CREATE DATABASE test_mysql_database' ) cursor.close() conn.close()
試したこと
terminal=>
,調べたを参考に
1,
sudo mysql.server start mysql -u root
2,
mysqlをけして、ダウンロードしました。
補足情報(FW/ツールのバージョンなど)
pycarm,最新のios,mac
ここにより詳細な情報を記載してください。
あなたの回答
tips
プレビュー