検索
my sql logo
記事の項目

最近の投稿

パスワード設定 MySQL

MySQLのroot パスワードの設定方法

この記事の項目

				
					$ sudo mysql_secure_installation
				
			
				
					Securing the MySQL server deployment.

Connecting to MySQL using a blank password.
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.

Skipping password set for root as authentication with auth_socket is used by default.
If you would like to use password authentication instead, this can be done with the "ALTER_USER" command.
See https://dev.mysql.com/doc/refman/8.0/en/alter-user.html#alter-user-password-management for more information.
				
			

MySQL サーバーのデプロイメントを保護します。

空のパスワードを使用して MySQL に接続します。
「validate_password」コンポーネントがサーバーにインストールされます。
後続の手順は既存の構成で実行されます。
コンポーネントの。

デフォルトでは auth_socket による認証が使用されるため、root に設定されたパスワードをスキップします。
代わりにパスワード認証を使用したい場合は、「ALTER_USER」コマンドを使用して実行できます。
詳細については、https://dev.mysql.com/doc/refman/8.0/en/alter-user.html#alter-user-password-management を参照してください。

				
					ALTER USER USER() IDENTIFIED BY 'auth_string';
				
			

USER() –> ‘root@localhost’

‘auth_string’ にはパスワードを記入するようだ。

mysql のログインは、Ubuntuの管理者のパスワードがあれば root ログインが可能です。

				
					$ sudo mysql -u root
				
			
				
					Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 26
Server version: 8.0.34-0ubuntu0.22.04.1 (Ubuntu)

Copyright (c) 2000, 2023, 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> 

				
			

難解なパスワードの制限を表示してみよう。

				
					mysql> show global variables like '%validate%';
+-------------------------------------------------+-------+
| Variable_name                                   | Value |
+-------------------------------------------------+-------+
| innodb_validate_tablespace_paths                | ON    |
| validate_password.changed_characters_percentage | 0     |
| validate_password.check_user_name               | ON    |
| validate_password.dictionary_file               |       |
| validate_password.length                        | 8     |
| validate_password.mixed_case_count              | 1     |
| validate_password.number_count                  | 1     |
| validate_password.policy                        | LOW   |
| validate_password.special_char_count            | 1     |
+-------------------------------------------------+-------+
9 rows in set (0.01 sec)
				
			
  • パスワード長 8文字以上
  • 大文字小文字 1文字以上
  • 数字 1文字以上
  • 記号 1文字以上

最低限含んでいるパスワードを設定する必要がある。

この制限に合わないときは、

				
					mysql> ALTER USER  'root'@'localhost' IDENTIFIED BY 'simple_passwd';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
				
			

のようなメッセージが表示される。

				
					mysql> ALTER USER  'root'@'localhost' IDENTIFIED BY 'strong_passwd';
Query OK, 0 rows affected (0.01 sec)
				
			

パスワードが設定されました。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

関連記事

Redis

$ sudo apt update $ sudo