{"id":353,"date":"2022-06-10T12:00:00","date_gmt":"2022-06-10T15:00:00","guid":{"rendered":"https:\/\/blog.wieczorek.com.br\/novo\/?p=353"},"modified":"2022-06-03T16:08:37","modified_gmt":"2022-06-03T19:08:37","slug":"trocar-plugin-de-autenticacao-no-mysql-mariadb","status":"publish","type":"post","link":"https:\/\/blog.wieczorek.com.br\/index.php\/2022\/06\/10\/trocar-plugin-de-autenticacao-no-mysql-mariadb\/","title":{"rendered":"Trocar plugin de autentica\u00e7\u00e3o no MySQL\/MariaDB"},"content":{"rendered":"\n<p>\u00c0 partir do MySQL Server 5.7, se n\u00e3o fornecermos uma senha para o usu\u00e1rio root durante a instala\u00e7\u00e3o, ele usar\u00e1 o plugin\u00a0<strong>auth_socket<\/strong>\u00a0para autentica\u00e7\u00e3o. Com esta configura\u00e7\u00e3o, o MySQL n\u00e3o se preocupar\u00e1 com sua senha de entrada, ele verificar\u00e1 se o usu\u00e1rio est\u00e1 se conectando usando um soquete UNIX e ent\u00e3o comparar\u00e1 o nome de usu\u00e1rio. Se for igual, voc\u00ea est\u00e1 autenticado!<\/p>\n\n\n\n<p>Erro ao fazer o login para o usu\u00e1rio root do MySQL a partir da conta de usu\u00e1rio normal do Linux:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">emilio@darthaemilius:~$ mysql -uroot -p\nEnter password:\nERROR 1698 (28000): Access denied for user 'root'@'localhost'<\/pre>\n\n\n\n<p>Vamos verificar o plugin de autentica\u00e7\u00e3o atual que o servidor MySQL est\u00e1 usando:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql> SELECT plugin from mysql.user where User='root';\r\n+-----------------------+\r\n| plugin                |\r\n+-----------------------+\r\n| auth_socket           |\r\n+-----------------------+<\/pre>\n\n\n\n<p>Para poder fazer o login com senha, voc\u00ea deve alterar o plugin de&nbsp;<strong>auth_socket<\/strong>&nbsp;para&nbsp;<strong>mysql_native_password<\/strong>. A seguir est\u00e1 o comando para fazer isso e criar uma nova senha.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql> UPDATE mysql.user SET plugin = 'mysql_native_password', authentication_string = PASSWORD('nova-senha') WHERE User = 'root';\r\nmysql> FLUSH PRIVILEGES;<\/pre>\n\n\n\n<p>Pronto. Agora voc\u00ea pode logar utilizando a nova senha.<\/p>\n\n\n\n<p>Este procedimento tamb\u00e9m resolve os seguintes problemas no PhpMyadmin:<\/p>\n\n\n\n<p><code>Can\u2019t log into phpMyAdmin: mysqli_real_connect(): (HY000\/1698): Access denied for user \u2018root\u2019@\u2019localhost\u2019<\/code><\/p>\n\n\n\n<p><code>mysqli::real_connect(): (HY000\/2002): Permission denied<\/code><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"420\" height=\"669\" src=\"https:\/\/blog.wieczorek.com.br\/novo\/wp-content\/uploads\/2022\/06\/101214444-55e75280-367c-11eb-99ff-532381842a4c.png\" alt=\"\" class=\"wp-image-355\" srcset=\"https:\/\/blog.wieczorek.com.br\/novo\/wp-content\/uploads\/2022\/06\/101214444-55e75280-367c-11eb-99ff-532381842a4c.png 420w, https:\/\/blog.wieczorek.com.br\/novo\/wp-content\/uploads\/2022\/06\/101214444-55e75280-367c-11eb-99ff-532381842a4c-188x300.png 188w\" sizes=\"auto, (max-width: 420px) 100vw, 420px\" \/><\/figure>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>\u00c0 partir do MySQL Server 5.7, se n\u00e3o fornecermos uma senha para o usu\u00e1rio root durante a instala\u00e7\u00e3o, ele usar\u00e1 o plugin\u00a0auth_socket\u00a0para autentica\u00e7\u00e3o. Com esta configura\u00e7\u00e3o, o MySQL n\u00e3o se preocupar\u00e1 com sua senha de entrada, ele verificar\u00e1 se o usu\u00e1rio est\u00e1 se conectando usando um soquete UNIX e ent\u00e3o [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":359,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[110,20,84,324,323,68,1],"tags":[113,327,73,322,329,328],"class_list":["post-353","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-banco-de-dados","category-desenvolvimento","category-linux","category-mariadb","category-mysql","category-php","category-sem-categoria","tag-mysql","tag-permissao","tag-php","tag-phpmyadmin","tag-plugin","tag-root"],"_links":{"self":[{"href":"https:\/\/blog.wieczorek.com.br\/index.php\/wp-json\/wp\/v2\/posts\/353","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.wieczorek.com.br\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.wieczorek.com.br\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.wieczorek.com.br\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.wieczorek.com.br\/index.php\/wp-json\/wp\/v2\/comments?post=353"}],"version-history":[{"count":4,"href":"https:\/\/blog.wieczorek.com.br\/index.php\/wp-json\/wp\/v2\/posts\/353\/revisions"}],"predecessor-version":[{"id":358,"href":"https:\/\/blog.wieczorek.com.br\/index.php\/wp-json\/wp\/v2\/posts\/353\/revisions\/358"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.wieczorek.com.br\/index.php\/wp-json\/wp\/v2\/media\/359"}],"wp:attachment":[{"href":"https:\/\/blog.wieczorek.com.br\/index.php\/wp-json\/wp\/v2\/media?parent=353"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.wieczorek.com.br\/index.php\/wp-json\/wp\/v2\/categories?post=353"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.wieczorek.com.br\/index.php\/wp-json\/wp\/v2\/tags?post=353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}