うかつにも MySql の root パスワードの設定時にタイプミスしていたようで、自分の覚えているパスワードを入力してもエラーになっております。
# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
しょうがないので以下のサイトを参考にパスワードをリセットします。
https://www.rackspace.com/knowledge_center/article/mysql-resetting-a-lost-mysql-root-password
まずは、mysqld が動作しているので停止します。
# /etc/init.d/mysqld stop
次に、mysqld_safe の –skip-grant-tables というオプションで実行。mysql をユーザー特権をスキップして開始する。(このオプションは –help でも表示されないので隠しオプションかな?)
アンパーサンド(&) をコマンドの末尾につけて実行します。
# mysqld_safe --skip-grant-tables &
そして、root でパスワードなしで実行。
# mysql -u root
以下、MySql コンソールで順次実行。ここでは、新しいパスワードを “new password” とします。
mysql> use mysql;
mysql> update user set password=PASSWORD("new password") where User='root';
mysql> flush privileges;
mysql> quit
最後に、mysqld を再起動します。
# /etc/init.d/mysqld stop
# /etc/init.d/mysqld start
新しいパスワードを確認してみます。
# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 2
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, 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.
以上です。無事リセットできました。 🙂