#author("2024-03-15T12:47:04+00:00","default:hotate","hotate")
#author("2024-03-15T22:04:15+00:00","default:hotate","hotate")
#contents
&tag(MySQL,トラブル);

* 情報 [#efdcde2f]
- [[MySQLエラー解決法(Mac編) #Rails - Qiita>https://qiita.com/ryouzi/items/7ace711d51ce291702bf]]
 開発環境はMacOSでHomebrewを使ってMySQLをインストールしています。


* 起動 [#a0b26368]
** [[MySQL/8.0]].23 [#ra349221]
- 問題:[[Homebrew]]を更新後、8.0.23が起動しない。(2021/06/19)
- 原因:8.0.23では、下記のようにProtobufの古いライブラリを参照していた。
 2021-06-20T02:22:59.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
 dyld: Library not loaded: /usr/local/opt/protobuf/lib/libprotobuf-lite.26.dylib
 Referenced from: /usr/local/opt/mysql/bin/mysqld
 Reason: image not found
-- Protobufの現バージョンにはそのようなライブラリが存在しない。
 $ ls /usr/local/Cellar/protobuf/3.17.3/lib
 libprotobuf-lite.28.dylib	libprotoc.28.dylib
 libprotobuf-lite.a		libprotoc.a
 libprotobuf-lite.dylib		libprotoc.dylib
 libprotobuf.28.dylib		pkgconfig
 libprotobuf.a			python3.9
 libprotobuf.dylib
-- Protobufの旧バージョンでは同ライブラリが存在していた。
 $ ls /usr/local/Cellar/protobuf/3.15.8/lib
 libprotobuf-lite.26.dylib	libprotoc.26.dylib
 libprotobuf-lite.a		libprotoc.a
 libprotobuf-lite.dylib		libprotoc.dylib
 libprotobuf.26.dylib		pkgconfig
 libprotobuf.a			python3.9
 libprotobuf.dylib
- 対策:[[Homebrew>Homebrew#td5844bf]]でProtobuf 3.15.8を再インストールした。(ビルドが行われるので少々時間がかかる)
 $ brew unlink protobuf
 $ brew tap-new foo/taps
 $ brew extract protobuf foo/taps --version 3.15.8
 $ brew install foo/taps/protobuf@3.15.8
 $ brew info protobuf@3.15.8
-- 後日、[[MySQL/8.0]].25へ更新して、Protobuf 3.15.8の再インストールは不要になった。Protobufが更新されたのだから、依存関係のある[[MySQL]]も更新されることを期待していたのだが、そうでは無いらしい。(2021/06/20)

** [[MySQL/8.0]].29 [#x63924a4]
- 問題:[[Homebrew]]で更新後、8.0.29が起動しない。(2022/05/22)
- 原因:touch /tmp/mysql.sock が存在しない為。
- 対策:touch /tmp/mysql.sock を作成した。(sudo を付けると権限の問題で起動に失敗する様子なので、付けない方が良い)
 $ touch /tmp/mysql.sock
- 情報:[[MySQLが起動しない(Can't connect to local MySQL server ~~)>https://zenn.dev/ogakuzuko/articles/6958a35833d4fd]]
 mysql.sockファイルを作成する(この段階で動くことが大半)
 sudo touch /tmp/mysql.sock

** [[MySQL/8.0]].30 [#zf0a3c0d]
- 問題:[[Homebrew]]で更新後、8.0.30が起動しない。(2024/03/15)
- 原因:不明。ログには下記のエラーメッセージとスタックトレースが出力されていた。
- 問題:[[Homebrew]]で更新後は動作したが、[[MacBookAir移行(2024年)]]後に8.0.30が起動しない。(2024/03/15)
- 原因:不明。ログには下記のエラーメッセージとスタックトレースが出力されていた。インストール環境と異なるのが原因?
 2024-03-15T10:43:52.290000Z 0 [ERROR] [MY-012153] [InnoDB] Trying to access page number 1768842507 in space 4294967278, space name innodb_undo_002, which is outside the tablespace bounds. Byte offset 0, len 16384, i/o type read. If you get this error at mysqld startup, please check that your my.cnf matches the ibdata files that you have in the MySQL server.
- 対策:仕方ないので新規フォルダへ再インストール後、バックアップデータをインポートした。(旧フォルダ /opt/homebrew/var/mysql はリネームして退避しておいた)
- 対策:新規フォルダへ再インストール後、[[バックアップ]]をインポートした。(旧フォルダ /opt/homebrew/var/mysql はリネームして退避した)


* [[バックアップ]] [#nf531545]
** [[MySQL/8.0]] [#cb29c802]
- 問題:下記のワーニングが発生する。([[2020]]/08/11)
 'Access denied; you need (at least one of) the PROCESS privilege(s) for this operation' when trying to dump tablespaces
- 原因:8.0.21から"PROCESS"権限が必要になっていた。
-- [[MySQL :: MySQL 8.0 Reference Manual :: 4.5.4 mysqldump — A Database Backup Program>https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html#option_mysqldump_no-tablespaces]]
 mysqldump requires at least the SELECT privilege for dumped tables, SHOW VIEW for dumped views, TRIGGER for dumped triggers, LOCK TABLES if the --single-transaction option is not used, and (as of MySQL 8.0.21) PROCESS if the --no-tablespaces option is not used. Certain options might require other privileges as noted in the option descriptions. 
- 対策:必要な権限を追加した。
- 参考:
-- [[mysql - 'Access denied; you need (at least one of) the PROCESS privilege(s) for this operation' when trying to dump tablespaces - Database Administrators Stack Exchange>https://dba.stackexchange.com/questions/271981/access-denied-you-need-at-least-one-of-the-process-privileges-for-this-ope]]

* ログイン [#qc3f3aff]
** [[MySQL/8.0]] [#m07a4bf6]
- 問題:インストール直後であるにも関わらず"root"でログイン出来ない。([[2021]]/05/09)
 $ mysql -u root            
 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
- 原因:環境変数"MYSQL_PWD"が残っている為(実は参照しているらしい)
- 対処:環境変数"MYSQL_PWD"を削除する。
 $ unset MYSQL_PWD

* JDBC [#vdc292be]
** 8.0.23 [#h59c1664]
- 問題:8.0.22での接続は成功するが、8.0.23以降での接続に失敗する。
 java.sql.SQLNonTransientConnectionException: Could not create connection to database server.
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
	at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:1006)
	at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:823)
	at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:453)
	at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
	at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198)
	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677)
	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:228)
- 情報:
-- [[MySQL Connector/J 8.0.23 has been released | InsideMySQL.com>https://insidemysql.com/mysql-connector-j-8-0-23/]]
-- [[MySQL :: MySQL Connector/J 8.0 Release Notes :: Changes in MySQL Connector/J 8.0.23 (2021-01-18, General Availability)>https://dev.mysql.com/doc/relnotes/connector-j/8.0/en/news-8-0-23.html]]
-- [[Support for Date-Time Types in Connector/J 8.0 | InsideMySQL.com>https://insidemysql.com/support-for-date-time-types-in-connector-j-8-0/]]
- 解決策:接続文字列に"connectionTimeZone=SERVER"を追加する。(2021/05/01)


* 関連 [#lb1d0be0]
#related

#taglist(tag=MySQL)

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS