質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

Linux

Linuxは、Unixをベースにして開発されたオペレーティングシステムです。日本では「リナックス」と呼ばれています。 主にWebサーバやDNSサーバ、イントラネットなどのサーバ用OSとして利用されています。 上位500のスーパーコンピュータの90%以上はLinuxを使用しています。 携帯端末用のプラットフォームAndroidは、Linuxカーネル上に構築されています。

ログイン

ログインは、ユーザーがコンピューターシステムにアクセスするプロセスの事を呼びます。

Q&A

解決済

1回答

3001閲覧

初期パスワードでMySQL8にログインできない

mikako23

総合スコア6

CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

Linux

Linuxは、Unixをベースにして開発されたオペレーティングシステムです。日本では「リナックス」と呼ばれています。 主にWebサーバやDNSサーバ、イントラネットなどのサーバ用OSとして利用されています。 上位500のスーパーコンピュータの90%以上はLinuxを使用しています。 携帯端末用のプラットフォームAndroidは、Linuxカーネル上に構築されています。

ログイン

ログインは、ユーザーがコンピューターシステムにアクセスするプロセスの事を呼びます。

0グッド

0クリップ

投稿2019/12/14 20:02

CentOSにてMySQLをダウンロードし、まずは初期パスワードでログインしようとしたところ、「ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)」が出てしまい、ログインできません。

ダウンロード時は下記の手順を参考にしました。
https://kitsune.blog/mysql-install

※ほぼ下記ご質問と同内容の問題となります。
https://teratail.com/questions/220686

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

↑でパスワードを変更しようとしてもダメでした。
(# systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"に設定しても変更不可)

気になる点としては、いったんMySQLをアンインストールして再ダウンロードしても、初期パスワードが一緒だった点です。

MySQLのログイン方法についてご教示いただけたら本当に助かります。よろしくお願いいたします。

■環境
ホスト側 OS : macOS Catalina バージョン10.15(19A602)
ゲスト側 OS : CentOS7.7.1908
仮想マシン: VirtualBox
mysqlバージョン:Ver 8.0.18 for Linux on x86_64 (MySQL Community Server - GPL)

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2019/12/15 03:41

パスワードを設定するのはrootユーザではなく、新しいアカウントで設定するのではダメなんでしょうか?
mikako23

2019/12/15 16:56

会社からの指示でなぜかrootユーザーでなければいけないんです。。
guest

回答1

0

ベストアンサー

気になる点としては、いったんMySQLをアンインストールして再ダウンロードしても、初期パスワードが一緒だった点です。

DBが残ってるのではないでしょうか。
DBを消して、再インストールしたら mysql_secure_installation で初期設定を行ってみてください。

◆Mysqlを削除

$ sudo yum -y remove mysql-* $ cd /var/lib $ sudo rm -rf ./mysql $ sudo rm /var/log/mysqld.log

◆Mysqlをインストール

$ sudo yum install -y mysql-community-server $ sudo systemctl start mysqld $ sudo systemctl enable mysqld

◆temporary password を確認

$ sudo grep password /var/log/mysqld.log 2019-12-15T08:11:20.017232Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 0vjgLjE->Td!

◆初期設定(↓は適当に入れてるだけなので内容は自身で確認してください)

$ sudo mysql_secure_installation Securing the MySQL server deployment. Enter password for user root: ← temporary password を入力 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) : N ... skipping. 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!

◆設定したパスワードでログイン

$ mysql -u root -p Enter password: ←先程設定したパスワードを入力 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 18 Server version: 8.0.18 MySQL Community Server - GPL Copyright (c) 2000, 2019, 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.

投稿2019/12/15 10:36

take88

総合スコア1351

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

mikako23

2019/12/15 16:57

ご教示いただいた方法でできました!本当にありがとうございます!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問