# [[chkconfig]] | grep "mysql"
mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
===[[Mac]](brewからクライアントのみインストール)===
<pre>
$ brew install mysql-client
</pre>
*インストールログの末尾を参照してPATHを通す
===権限の初期設定===
*http://dev.mysql.com/doc/refman/5.1-olh/ja/unix-post-installation.html
*http://dev.mysql.com/doc/refman/4.1/ja/resetting-permissions.html
=====[[Ubuntu]] 初期パスワードの場所=====
----
*確認
<pre>
====初期の権限変更ツール mysql_secure_installation====
----
*初期パスワード /var/log/mysqld.log | grep "temporary password"
# mysql_secure_installation
Cleaning up...
=====Failed! Error: SET PASSWORD has no significance for user... エラー=====
----
*上記「Ubuntu 初期パスワードの場所」のユーザーでログイン
<pre>
Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y
... Failed! Error: SET PASSWORD has no significance for user 'root'@'localhost' as the authentication method used doesn't store authentication data in the MySQL server. Please consider using ALTER USER instead if you want to change authentication parameters.
</pre>
*ループから抜け出せない、以下のプロンプトでCtrl+C
<pre>
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) :
</pre>
*https://dev.mysql.com/doc/refman/8.0/ja/resetting-permissions.html
<pre>
ubuntu@ip-172-26-11-57:~$ mysql -u debian-sys-maint -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.30-0ubuntu0.20.04.2 (Ubuntu)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
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> set password for 'root'@'localhost' = 'NewPassword';
ERROR 4102 (HY000): SET PASSWORD has no significance for user 'root'@'localhost' as the authentication method used doesn't store authentication data in the MySQL server. Please consider using ALTER USER instead if you want to change authentication parameters.
</pre>
*以下で成功!
<pre>
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by 'NewPassword';
Query OK, 0 rows affected (0.01 sec)
</pre>
<pre>
mysql> select version();
+-------------------------+
| version() |
+-------------------------+
| 8.0.30-0ubuntu0.20.04.2 |
+-------------------------+
1 row in set (0.00 sec)
</pre>
===簡易設定===
====バージョンの確認====
===[[phpMyAdmin]]===
*[[phpMyAdmin]]
===ポートフォワーディング===
*ssh -i 踏み台サーバー鍵ファイル -L ローカルポート:本当に接続したいサーバー:本当に接続したいサーバーのポート 踏み台サーバーユーザー@踏み台サーバー
<pre>
$ ssh -i ~/.ssh/typea-dev-key.pem -L 13308:typea-dev-mysql-multiaz.c5ihdpszudfw.us-east-1.rds.amazonaws.com:3306 ec2-user@34.226.213.144
</pre>
RDSにEC2を踏み台にして、SQLWorkbentchから接続
[[File:port_forwarding.png|600px]]
==管理==
kill [Id]
==[[SQL]]==
===カンマ区切り文字列をSplitする===
SUBSTRING_INDEX(comma_string,',',1),
SUBSTRING_INDEX(SUBSTRING_INDEX(comma_string,',',1),',',1),
SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING_INDEX(comma_string,',',1),',',1),',',1),
SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING_INDEX(comma_string,',',1),',',1),',',1),',',1)
===制約を無視してテーブルをtruncateする===
----
mysql> truncate table hoge;
mysql> SET FO[[R]]EIGN_KEY_CHECKS=1;
===パーティショニング===
----