Skip to content

mysql opr records

steps to solove mariadb ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)

1
2
3
sudo systemctl stop mariadb.service
# kill mariadb.pid
vi /etc/my.cnf

under [mysqld] add following line skip-grant-tables

1
2
sudo systemctl start mariadb.service
mysql -u root
1
2
3
update mysql.user set Password=password('xxx') where User='root', Host='localhost';
flush privileges;
quit

restore my.cnf

1
sudo systemctl restart mariadb.service

Special cases:

check if localhost for root exists check plugin is empty check error info, the host after root

mysql add user and enable remote connect

1
2
3
4
create user wl identified by 'wl';
GRANT ALL privileges on *.* to wl@'%' identified by 'wl';
flush privileges;
show grants for wl;

incase firewall has been enable

1
2
3
4
5
6
7
centos 7
sudo firewall-cmd --list-ports
sudo firewall-cmd --zone=public --add-port=3306/tcp --permanent
sudo firewall-cmd --reload
sudo systemctl stop firewalld.service
sudo systemctl disable firewalld.service
firewall-cmd --zone=public --remove-port=80/tcp --permanent

Github based Comments, sign in Github required.