#author("2020-09-13T13:50:40+00:00","default:src128","src128")
#author("2020-10-02T11:49:55+00:00","default:src128","src128")
&tag(MySQL8);
*目次 [#n451abf1]
#contents
*関連ページ [#o3976052]
*参考情報 [#fc93aae4]

*設定 [#d805ca20]

**export/importでcollateが異なってしまう [#r7f695c4]
-mysqldumpによるexport時、create tableのcharsetがutf8mb4で、collateが指定していない場合、
-import時にcollateがutf8mb4_0900_ai_ciになってしまう(collation-serverがutf8mb4_binでも)。
-これはcharsetだけ指定されている場合、そのcharsetのデフォルトのcollateが指定されるというmysqlの仕様らしい。[[MySQL :: MySQL 5.6 リファレンスマニュアル :: 10.1.3.3 テーブル文字セットおよび照合順序:https://dev.mysql.com/doc/refman/5.6/ja/charset-table.html]]
-これを避けるためには、charsettとcollateをcreate tableで明示しておいたほうがよいっぽい。

**既存のテーブルのcollateを一括設定 [#zd9a2c93]
-[[mysql - How to convert all tables in database to one collation? - Stack Overflow:https://stackoverflow.com/questions/10859966/how-to-convert-all-tables-in-database-to-one-collation/10860122#10860122]]
-以下のコマンドでcollateを変更するSQLを生成できる。以下をcollate.sqlとして保存。
#pre{{
SELECT CONCAT("ALTER TABLE ", TABLE_SCHEMA, '.', TABLE_NAME," COLLATE utf8mb4_bin;") AS ExecuteTheString
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA="mydb"
AND TABLE_TYPE="BASE TABLE";
}}
-以下のように実行してファイルに保存。
 mysql --skip-column-names < collate.sql > collate_change.sql
-collate_change.sqlの内容を確認。。
 ALTER TABLE mydb.test_table COLLATE utf8mb4_bin;
 (...)
-実行。環境によって少し時間が必要かも。
 mysql < collate_change.sql

*トラブルシューティング [#e0e84702]
**「grant all privileges」でエラー [#l935e464]
-MySQL 8ではcreate userしてからgrantしないとだめらしい。
-[[How to grant all privileges to root user in MySQL 8.0 - Stack Overflow:https://stackoverflow.com/questions/50177216/how-to-grant-all-privileges-to-root-user-in-mysql-8-0]]
#pre{{
mysql> CREATE USER 'root'@'%' IDENTIFIED BY 'root';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
}}

**unknown variable 'validate_password.policy=LOW'が表示される [#t420709a]
-どうやらvalidate_password componentが有効でないとこのエラーが表示されるらしい。[[MySQL :: MySQL 8.0 Reference Manual :: 6.4.3.3 Transitioning to the Password Validation Component:https://dev.mysql.com/doc/refman/8.0/en/validate-password-transitioning.html]]
-以下のコマンドで確認できる。[[MySQL8.0 小ネタ集 | スマートスタイル TECH BLOG|データベース&クラウドの最新技術情報を配信:https://www.s-style.co.jp/blog/2018/07/2106/]]
 SELECT * FROM mysql.component;
-CentOS 8ではデフォルトでvalidate_passwordコンポーネントが有効だが、macportsでは無効?(要確認)。


**リモートから接続できない [#l5d6c2e6]
-skip-networking、bind-addressの設定を確認する。以下はリモートアクセスを許可する設定。
#pre{{
bind-address=0.0.0.0
skip-networking=0
}}
-現在の設定はこれで確認できる。
 $ mysql -b -e "SHOW GLOBAL VARIABLES like 'bind_address'"
-それでもだめな場合ユーザー(rootなど)のアクセス許可がlocalhostに限定されているせいかもしれない。
 select user,host from mysql.user;
 | root             | localhost |
-以下で作成する。 
 create user root@'%' identified by 'hogehoge';
 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
**mysqldump: Error: 'Access denied; you need (at least one of) the PROCESS privilege(s) for this operation' when trying to dump tablespaces [#he9ca9a4]
-[[mysqldumpでPROCESS権限(PROCESS privilege)を要求される - いっさいがっさい:https://isgs-lab.com/424/]]
-以下を実行。
 mysql > GRANT PROCESS ON *.* TO "your-user";


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS