Главная » Статьи » Linux

Restore access mysql after update Access denied for user 'root'@'localhost'
List command to execute to restore acces from root with empty password
WARN! Use it only for development machine
 
sudo /etc/init.d/mysql stop
sudo killall mysqld_safe
sudo killall mysqld
sudo mysqld_safe --skip-grant-tables &
mysql -u root
use mysql;
update user set password=PASSWORD("mynewpassword") where User='root';
update user set plugin="mysql_native_password";
quit;
sudo /etc/init.d/mysql stop
sudo kill -9 $(pgrep mysql)
sudo /etc/init.d/mysql start

Mysql 5.7 change password on authentication_string 

Link to bash script: 

https://gist.github.com/iamsimakov/040bfaab263b8dd051569b65857ab431


ex output

username@alexey-host:~$ sudo killall mysqld_safe
mysqld_safe: процесс не найден
username@alexey-host:~$ sudo killall mysqld
username@alexey-host:~$ sudo mysqld_safe --skip-grant-tables &
[1] 6241
username@alexey-host:~$ 2016-05-26T08:02:28.451043Z mysqld_safe Logging to syslog.
2016-05-26T08:02:28.453160Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2016-05-26T08:02:28.467126Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

username@alexey-host:~$ mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.12-0ubuntu1 (Ubuntu)

Copyright (c) 2000, 2016, 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.

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set password=PASSWORD("mynewpassword") where User='root';
ERROR 1054 (42S22): Unknown column 'password' in 'field list'
mysql> update user set authentication_string=PASSWORD("root") where User='root';
Query OK, 1 row affected, 1 warning (0,00 sec)
Rows matched: 4  Changed: 1  Warnings: 1

mysql> update user set plugin="mysql_native_password";
Query OK, 0 rows affected (0,00 sec)
Rows matched: 6  Changed: 0  Warnings: 0

mysql> \q
Bye

 

Bash script:

#!/bin/bash

 

function log {

echo $@

}

 

function stop_mysql_server {

log 'Stopping'

sleep 2

sudo /etc/init.d/mysql stop

sleep 2

sudo killall mysqld_safe

sleep 2

sudo killall mysqld

sleep 2

}

 

function mkdir_sock_mysql {

log 'Make dir /var/run/mysqld'

sudo mkdir -p /var/run/mysqld

sudo chown mysql. -R /var/run/mysqld

sudo chmod 0755 /var/run/mysqld

sleep 1

}

 

function start_mysql_skip_grant {

log 'Start skip grant'

sudo mysqld_safe --skip-grant-tables &

sleep 5

}

 

function exec_query {

log $@

mysql -u root mysql -e $@

}

 

function start_mysql {

log 'Start mysql'

sudo /etc/init.d/mysql start

}

 

stop_mysql_server

mkdir_sock_mysql

start_mysql_skip_grant

exec_query "update user set authentication_string=PASSWORD('') where User='root'; update user set plugin='mysql_native_password';"

stop_mysql_server

start_mysql

 

 

 

 



Источник: http://askubuntu.com/questions/705458/ubuntu-15-10-mysql-error-1524-unix-socket
Категория: Linux | Добавил: iamsimakov (2016-05-26)
Просмотров: 1067 | Рейтинг: 0.0/0
Всего комментариев: 0
avatar