MySQL 5.7 senha root gerada automaticamente

Fala pessoal.

Vocês devem ter notado algo diferente quando instalaram o MySQL 5.7 do zero, seja via yum ou pelos binários que o MySQL disponibiliza. O password do usuário root é gerado automaticamente.
Ok, e aonde eu posso encontra-lo ?

Centos
cat /var/log/mysqld.log | grep "A temporary password is generated for" | awk '{print $NF}'
Examplo:

[root@master ~]# cat /var/log/mysqld.log | grep "A temporary password is generated for" | awk '{print $NF}'
a3BGf#TY.pBj

Versão binária
Quando você rodou o comando para inicializar o datadir mysqld --initialize você verá a seguinte mensagem na sua tela:

. . .
2016-01-13T21:05:03.070322Z 1 [Note] A temporary password is generated for root@localhost: vL8n>Hs%kr>s
. . .

Você terá que alterar a senha do usuário no primeiro login. Você pode fazer isso seguindo o passo 2 deste artigo.

É isso aí.
Agora vocês já sabem aonde encontrar a senha do root que foi gerada automaticamente na instalação.

Até a próxima.

Gostou ? Ajude e Compartilhe!
This entry was posted in instalação, MySQL, password, Security. Bookmark the permalink.
  • http://dasini.net/blog Olivier DASINI

    Hi,
    I would like to add since MySQL 5.7.11, the default value of the default_password_lifetime system variable that controls the global password expiration policy has been changed from 360 (360 days) to 0 (no password expiration).
    https://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-11.html
    That probably would avoid the “1 yr later big panic” 😉

    • Marcelo Altmann

      Thanks for the valuable comment!

      • Emin

        Marcelo, thanks for this post. I have been having this problems for several days and I would appreciate it if you could help me out

        I downloaded MySQL and didn’t jot down the temporary password that pops on the screen. Since then, I have not been able to reset my root password. No matter where I search, I can’t find a solution. Any help?

        • Marcelo Altmann
          • Emin

            So I am typing in the terminal.
            /etc/init.d/mysql stop
            this popped up -bash: /etc/init.d/mysql: No such file or directory
            what should I do??
            Thanks so much for offering this prompt help! Quickest response I got on line so far! Thanks for helping me fix this issue.

            I stopped server thru system preference manually and tried next step

            mysqld_safe-skip-grant-tables

            that also gave this

            -bash: mysqld_safe-skip-grant-tables: command not found

            Sorry I am newbie. Hopefully we fix this so I continue to learn

          • Marcelo Altmann

            As you already stopped the service, go to /etc/my.cnf and add skip-grant-tables right after [mysql] (line below)

            then start the service again, login with any user, and change the password like in the article I sent on my above comment. Then remove the skip-grant-tables from my.cnf and restart the service .
            Try to login with your new pwd.

          • Emin

            Marcelo, i am so sorry I don’t understand what “go to /etc/my.cnf and add skip-grant-tables right after [mysql] (line below)” refers to

            I have only terminal and server to stop or run. do i need to have other files?

            Can you type in step by step so i can copy and paste the code to see how it works and learn from there if i need type in your instruction in the terminal? Because I translated your first instruction into this and it doesn’t seem right
            /etc/my.cnf-skip-grant-tables
            gave this -bash: /etc/my.cnf-skip-grant-tables: No such file or directory

          • Marcelo Altmann

            Hi Emin,
            I mean open the file on the file editor (vim / nano / gedit), add a new line and type skip-grant-tables. Save the file and restart mysql service

          • Emin

            I have terminal, sublime text and mysql-5.7.13-osx10.11-x86_64.pkg. There are no files that I can go to. when I go to (mysql-5.7.13-osx10.11-x86_64.pkg) there is no files but it goes to installation again.

            Thanks for patiently helping me figure this out.

          • Emin

            Hey Marcelo,

            I was wondering if you could help me out with the following issue. thanks!

            I have terminal, sublime text and mysql-5.7.13-osx10.11-x86_64.pkg. There are no files that I can go to. when I go to (mysql-5.7.13-osx10.11-x86_64.pkg) there is no files but it goes to installation again.

            a) I have this installed

            https://dev.mysql.com/doc/refm

            b) Do I need to install MySQL Launch Daemon as well?

            https://dev.mysql.com/doc/refm

            c) And the MySQL Preference Pane?

            or all of this(b and c) is already installed when installed what(a) I have now?

            Sorry i am very confused with all this.

            Thanks for patiently helping me figure this out.

          • Emin

            Marcelo, any help above comments? Thanks!