12
7

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.

EC2 MySQL 初期設定 root にパスワードの設定

Posted at

##前提条件
EC2にMySQLのインストールがすんでいる

##設定

[ec2-user@ip-・・・・・ ~]$ sudo /etc/init.d/mysqld start
                                                              [OK]

起動

[ec2-user@ip-・・・・・ ~]$ sudo mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): 

「Enterキー」

OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] y

パスワードをセットするか聞かれるから**「yキー」から「Enterキー」**

New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!

設定するパスワードを入力して**「Enterキー」**
確認で求められるから、もう1度、入力

Remove anonymous users? [Y/n] y
 ... Success!

Disallow root login remotely? [Y/n] y
 ... Success!

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reload privilege tables now? [Y/n] y
 ... Success!
Cleaning up...

上から、

  • 匿名ユーザーを削除するかどうか。
  • rootユーザーのリモートホストからのログインを無効化するかどうか。
  • testデータベースを削除するか。
  • これらの変更を即座に反映するか。
    全部問題無いので**「yキー」から「Enterキー」**
Thanks for using MySQL!

設定完了

##ログイン

[ec2-user@ip-・・・・・・ ~]$ mysql -u root -p
Enter password: 

先ほど設定したパスワードを入力

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.5.60 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

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>

実際に入れたら成功

12
7
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
12
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?