LoginSignup
2
3

More than 5 years have passed since last update.

Ubuntu16.04でmysql5.7をChefでインストール

Last updated at Posted at 2016-07-08

レシピで下のような感じでインストールすると、

%w(mysql-server mysql-client).each do |pkg|
  package pkg do
    action :install
  end
end

rootでログインできない・・・。

$ mysql -uroot
ERROR 1698 (28000): Access denied for user 'root'@'localhost'

結論

一回、データディレクトリを削除して、--initialize-insecureで再作成する。

$ sudo rm -fr /var/lib/mysql
$ sudo mkdir /var/lib/mysql
$ sudo chown mysql:mysql /var/lib/mysql
$ sudo /usr/sbin/mysqld --initialize-insecure --user=mysql --datadir=/var/lib/mysql

こうすると、パスワードなしでログインできる

$ mysql -uroot

色々調べてみた過程

–skip-grant-table付で起動して、パスワードを変更する

起動できて、ログインも出来るけど、パスワード変更はできない。というか反映されない。

/root/.mysql_secret

これはMySQL5.6ね。インストールしたいのは、5.7

$ cat /var/log/mysqld.log | grep "temporary password"
2016-05-16T07:09:49.796912Z 1 [Note] A temporary password is generated for root@localhost: 8)13ftQG5OYl

これは、CentOSね。インストールしたいOSはubuntu

結局のところ、インストールした時に以下のログ出るので、それに従えばよいのですわ。

root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2
3
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
2
3