红联Linux门户
Linux协助

处理MariaDB无暗码就能够登录的问题

发布时刻:2017-12-08 09:25:40来历:linux网站作者:Dicky_Zhang
问题:
困扰了好久的问题
运用apt-get来装置mysql,装置好之后发现装置的是 MariaDB,如下,无需暗码既能够登录了。即便运用mysqladmin设置好暗码,用暗码登录能够,不必暗码登录也能够
root@ubuntu:/etc/mysql# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 35
Server version: 10.0.31-MariaDB-0ubuntu0.16.04.2 Ubuntu 16.04
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
排查思路:
榜首看看my.conf有没有skip-grant-tables,越过暗码验证
过滤了下没有
处理MariaDB无暗码就能够登录的问题
看看my.cnf里边是不是把暗码写进去了,查找了相关.cnf文件去看了看也没有
root@ubuntu:~# find / -name "*.cnf"
/usr/share/ssl-cert/ssleay.cnf
/usr/share/dovecot/dovecot-openssl.cnf
/usr/lib/ssl/openssl.cnf
/etc/ssl/openssl.cnf
/etc/alternatives/my.cnf
/etc/mysql/my.cnf
/etc/mysql/mariadb.cnf
/etc/mysql/conf.d/mysqldump.cnf
/etc/mysql/conf.d/mysql.cnf
/etc/mysql/mariadb.conf.d/50-mysqld_safe.cnf
/etc/mysql/mariadb.conf.d/50-mysql-clients.cnf
/etc/mysql/mariadb.conf.d/50-client.cnf
/etc/mysql/mariadb.conf.d/50-server.cnf
/etc/mysql/debian.cnf
/var/lib/dpkg/alternatives/my.cnf
root@ubuntu:~# 
不过有个小发现:
vim /etc/mysql/debian.cnf
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host     = localhost
user     = root
password = 
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host     = localhost
user     = root
password = 
socket   = /var/run/mysqld/mysqld.sock
basedir  = /usr
看了阐明是以上由脚本生成,不要改动,
尽管这样写,我也去改了下,加上暗码,重启仍是不可
最终的最终,去查找了好久,总算有发现了,是用户插件问题。
榜首我去跟装置正常的mysql来比较下,如下
处理MariaDB无暗码就能够登录的问题
处理MariaDB无暗码就能够登录的问题
看到这儿应该发现问题了,依照正常的修正就行了
sudo service mysql stop
sudo mysqld_safe --skip-grant-tables
进去mysql履行如下指令:
MariaDB [(none)]> UPDATE mysql.user SET authentication_string = PASSWORD('mypassword'), plugin = 'mysql_native_password' WHERE User = 'root' AND Host = 'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;
验证:
处理MariaDB无暗码就能够登录的问题
先kill掉mysql  kill -9 pid
发动:
sudo service mysql start
最终验证下:需求暗码了
root@ubuntu:~# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
root@ubuntu:~#
 
本文永久更新地址:http://www.138comgov138.com/linux/32993.html