MySQL 5.7 senha root gerada automaticamente

Fala pessoal.

Vocês devem ter notado algo diferente quando instalaram o MySQL 5.7 ou 8.0 do zero, seja via yum ou pelos binários que o MySQL disponibiliza. O password do usuário root é gerado automaticamente nestas versões.
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.

13 thoughts on “MySQL 5.7 senha root gerada automaticamente

      1. 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?

      2. 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

      3. 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.

      4. 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

      5. 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

      6. 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.

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

  1. That’s great! Thanks,
    Do you know how to prevent MySql from generating a random password and instead use the once chosen by the user when running mysqld –initialize ? I want to force using a password on a no install version distributed with a standalone application 🙂

Deixe uma resposta

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *