両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン |
linux:mysql [2024/05/21 12:23] – [MySQL の設定] ともやん | linux:mysql [2024/05/22 00:34] (現在) – [UNIX ドメインソケット経由で接続エラーになる場合] ともやん |
---|
| |
==== ログイン確認 ==== | ==== ログイン確認 ==== |
root にてログインできることを確認する。 | mariadb の root にてログインできることを確認する。 |
<code> | <WRAP color_term> |
$ mysql -u root -p | <WRAP color_command><html><pre> |
Enter password: ******** <- root ユーザーのパスワードを入力 | <font color="#0087FF"><b>$</b></font> <font color="#26A269">mysql</font> <font color="#A347BA">-u</font> root <font color="#A347BA">-p</font> |
Welcome to the MySQL monitor. Commands end with ; or \g. | </pre></html></WRAP> |
Your MySQL connection id is 4 | <WRAP color_result><html><pre> |
Server version: 5.0.77 Source distribution | Enter password: ******** <b class=DiY><- root ユーザーのパスワードを入力</b> |
| <b>Welcome to the MariaDB monitor. Commands end with ; or \g.</b> |
| <b>Your MariaDB connection id is 54</b> |
| <b>Server version: 10.11.6-MariaDB-log Alpine Linux</b> |
| |
Type 'help;' or '\h' for help. Type '\c' to clear the buffer. | <b>Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.</b> |
| |
mysql> | <b>Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.</b> |
</code> | |
| MariaDB [(none)]> \q |
| <b>Bye</b> |
| </pre></html></WRAP> |
| </WRAP> |
| |
| === UNIX ドメインソケット経由の接続エラー === |
| <WRAP round tip minfont_12 90%> |
| UNIX ドメインソケット経由でローカルサーバーに接続できない場合は...🤪\\ |
| <WRAP color_term> |
| <WRAP color_command><html><pre> |
| <font color="#0087FF"><b>$</b></font> <font color="#26A269">mysql</font> <font color="#A347BA">-u</font> root <font color="#A347BA">-p</font> |
| </pre></html></WRAP> |
| <WRAP color_result><html><pre> |
| Enter password: |
| ERROR 2002 (HY000): Can't connect to local server through socket '/var/lib/mysql/mysql.sock' (2) |
| </pre></html></WRAP> |
| </WRAP> |
| |
| 同一コンピューター内なので UNIX ドメインソケット (mysql.sock) で通信しようとするが、__Podman や Docker などのコンテナ仮想化では別マシンと通信するときと同様に TCP/IP ソケット通信でなければ接続できない。__\\ |
| |
| <html><code>-h ::1</code></html> オプションで IPv6/IPv4 ローカルホストアドレスを指定すると TCP/IP ソケット通信にできる😉\\ |
| または、<html><code>-P 3306</code></html> オプションでポート指定することでも同様に通信できる😊\\ |
| <WRAP color_term> |
| <WRAP color_command><html><pre> |
| <font color="#0087FF"><b>$</b></font> <font color="#26A269">mysql</font> <font color="#A347BA">-u</font> root <font color="#A347BA">-h</font> ::1 <font color="#A347BA">-p</font> |
| or |
| <font color="#0087FF"><b>$</b></font> <font color="#26A269">mysql</font> <font color="#A347BA">-u</font> root <font color="#A347BA">-h</font> 127.0.0.1 <font color="#A347BA">-p</font> |
| or |
| <font color="#0087FF"><b>$</b></font> <font color="#26A269">mysql</font> <font color="#A347BA">-u</font> root <font color="#A347BA">-P</font> 3306 <font color="#A347BA">-p</font> |
| </pre></html></WRAP> |
| <WRAP color_result><html><pre> |
| Enter password: |
| <b>Welcome to the MariaDB monitor. Commands end with ; or \g.</b> |
| <b>Your MariaDB connection id is 54</b> |
| <b>Server version: 10.11.6-MariaDB-log Alpine Linux</b> |
| |
| <b>Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.</b> |
| |
| <b>Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.</b> |
| |
| MariaDB [(none)]> \q |
| <b>Bye</b> |
| </pre></html></WRAP> |
| </WRAP> |
| 参考: [[so>questions/4448467/cant-connect-to-local-mysql-server-through-socket-var-lib-mysql-mysql-sock|Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) - Stack Overflow]]\\ |
| </WRAP> |
| |
===== データベース作成 ===== | ===== データベース作成 ===== |