17
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

mysql_secure_installation の初期パスワード確認

Posted at

#経緯
MySQLの設定をする際に初期パスワードが自動発行されていることを知らなかったため、記事に残しました。

Conohaのサポートブログ
https://support.conoha.jp/v/setupmysql/

#問題点

▼SQLのセキュリティ設定の際に下記のエラーで躓いてしまった

$ mysql_secure_installation
Securing the MySQL server deployment.

Enter password for user root: 
Error: Access denied for user 'root'@'localhost' (using password: YES)

#解決

どうやらSQLには初期パスワードが事前に発行されているようです。
初期パスワードの格納場所は/var/log/mysqld.log
▼root@localhost:の後ろが初期パスワードです

$ cat /var/log/mysqld.log

~~省略~~
[Note] [MY-010454] [Server] A temporary password is generated for root@localhost: [初期パスワード]

mysql_secure_installationで初期パスワードを入力し新しいパスワードを設定


$ mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root: [初期パスワード]

The existing password for the user account root has expired. Please set a new password.

New password: [新しいパスワード]

Re-enter new password: [もう一度新しいパスワード]
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Using existing password for root.

Estimated strength of the password: 100 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y

New password: [新しいパスワード]

Re-enter new password: [もう一度新しいパスワード]

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
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done! 

▼参考サイト
https://weblabo.oscasierra.net/mysql-57-init-setup/

17
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?