my20_mysql的本地用户无法连接到数据库
mysql的本地用户无法连接到数据库
$ mysql -uadmin -prootroot -hlocalhost -P3309
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/data/mysql/mysql.sock' (2)
查看帮助
mysql --help
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
The following groups are read: mysql client
The following options may be given as the first argument:
--print-defaults Print the program argument list and exit.
--no-defaults Don't read default options from any option file,
except for login file.
--defaults-file=# Only read default options from the given file #.
--defaults-extra-file=# Read this file after the global files are read.
--defaults-group-suffix=#
Also read groups with concat(group, suffix)
--login-path=# Read this path from the login file.
/etc/my.cnf 里面果然有下面一行,mysql默认读了/etc/my.cnf,可该实例的配置文件并不是/etc/my.cnf,所以就出错了
socket = /data/mysql/mysql.sock
配置文件寻找顺序
1. 命令行中的 --defaults-file=
2. 依次 /etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
虽然找到了原因,但由于该服务器是多实例,/etc/my.cnf有实例在用,尝试以下参数使用情况
加--no-defaults参数变成了读/tmp/mysql.sock
# mysql --no-defaults -uadmin -prootroot -hlocalhost -P3306
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
添加--defaults-file参数可以登录
# mysql --defaults-file=/etc/my_vodb.cnf -uadmin -prootroot -hlocalhost -P3306
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
admin@localhost Fri Oct 12 16:36:45 2018 16:36:45 [(none)]>
使用127.0.0.1却可以直接登录
# mysql -uadmin -prootroot -h127.0.0.1 -P3306
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
另外以下方式也是可以登录的
mysql --no-defaults -uadmin -pu5EvNtomhXdvr23 -h127.0.0.1 -P3309
mysql --defaults-file=/etc/my_tanpf.cnf -uadmin -pu5EvNtomhXdvr23 -h127.0.0.1 -P3309
除了以上原因外,还有一种情况就是密码错了,就算你非常确定密码没有错,不防更新一下密码,再连接一下试试
alter user `admin`@`127.0.0.1` identified by '原来的密码';
当然加-S参数也是可以的,这里就是找一找为什么有时会连接不上的原因
mysql -uadmin -prootroot -S /data/mysql/log/test/mysql_test.sock
如果出现了127.0.0.1可以登录,但localhost却不可以登录的情况,确保存在localhost用户的情况下,应该是网络解析或mysql内部的问题,所以,创建本地用户,优先使用127.0.0.1
my20_mysql的本地用户无法连接到数据库的更多相关文章
- 修改本地配置远程连接oracle数据库
当我们需要查看数据库信息时,我们更愿意通过客户端来查看,这样不仅操作方便,而且查看更精准.那么需要远程连接数据库需要在本地修改那些配置呢?以下是我个人的经验,希望大家都指正. 1.在oracle安装目 ...
- 创建新用户,连接Oracle数据库
1.sys用户是最高管理员用户,那我们就用这个sys用户登录oracle:
- 如何使用本地账户"完整"安装 SharePoint Server 2010+解决“New-SPConfigurationDatabase : 无法连接到 SharePoint_Config 的 SQL Server 的数据 库 master。此数据库可能不存在,或当前用户没有连接权限。”
注:目前看到的解决本地账户完整安装SharePoint Server 2010的解决方案如下,但是,有但是的哦: 当我们选择了"完整"模式安装SharePointServer201 ...
- oracle中所有存在不存在的用户都可以使用dba连接到数据库
oracle中所有存在不存在的用户都可以使用dba连接到数据库及解决方式 以前一直使用conn /as sysdba连接数据库,不明白里面的意思.今天无意中使用其他的用户名密码连接到dba竟然也可以( ...
- 如何设置FreePBX的数据库用户可以通过远程来连接Mysql数据库?
要满足mysql允许通过除了本机外的主机进行使用客户端连接的方法: 要设置root用户允许通过外网用户进行连接访问的操作方法: 1.首先先改mysql的配置文件 将绑定的#bind-address = ...
- 通过SSH隧道的本地转发实现Django连接远程数据库
SSH连接命令 默认连接的端口为22 1. 使用私钥 ssh -p connect_port user_name@host -i your_private_identity 2. 使用用户密码 ssh ...
- 普通用户从其他主机连接MySQL数据库
一.登陆数据库 mysql -u root -p [超级用户密码]; 二.创建新用户 CREATE USER 'username'@'host' IDENTIFIED BY 'password'; 参 ...
- Navicat连接Oracle数据库用户权限问题
解决Navicat连接Oracle数据库用户权限问题: 第一步:在cmd窗口运行[sqlplus], 第二步:输入Oracle的用户名和口令连接Oracle数据库, 第三步:执行授权代码,给用户授予D ...
- PLSQL连接本地oracle或远程oracle数据库,实现随意切换
转: PLSQL连接本地oracle或远程oracle数据库,实现随意切换 置顶 2018年01月12日 19:36:45 前方一片光明 阅读数 43542 版权声明:本文为博主原创文章,未经博主 ...
随机推荐
- Etyma01 ced ceed cess
一. etyma ['ɛtə,mə] ced.ceed.cess -> go -> 行走,前进 二.for instance 1. precede=pre+ced+e pre- 在前 2. ...
- php学习笔记-do while循环
do{ func(); }while(condition) do while执行逻辑是先执行循环体里面的代码,再判断condition是否为true,如果是则和while循环一样了.如果conditi ...
- PDF的一些工具
PdfStreamDumper Pdftk 这里有一个链接,列出了很多pdf免费工具 https://en.wikipedia.org/wiki/Category:Free_PDF_software ...
- 前端学习笔记2017.6.12 HTML的结构以及xhtml、html、xml的区别
HTML的结构 一个HTML文档可分为几个部分,如下图所示: DOCTYPE部分.head部分和body部分 DOCTYPE部分,这个很重要,可以理解为不同的DOCTYPE意味着不同的html标准,因 ...
- 算法Sedgewick第四版-第1章基础-008一用数组实现栈(泛型、可变大小)
package algorithms.ADT; /*************************************************************************** ...
- Entity Framework Tutorial Basics(23):Add Single Entity
Add New Entity using DBContext in Disconnected Scenario: In this chapter you will learn how to add n ...
- format Code
setting中设置format code. 方便格式化代码.
- 在windows远程提交任务给Hadoop集群(Hadoop 2.6)
我使用3台Centos虚拟机搭建了一个Hadoop2.6的集群.希望在windows7上面使用IDEA开发mapreduce程序,然后提交的远程的Hadoop集群上执行.经过不懈的google终于搞定 ...
- Umbraco中如何找到home node
在一个Umbraco项目中,我们经常会出现需要找到这个项目的home node的情况, 那么如何来找到项目的home node呢 方法如下: 1. 在View中 @inherits Umbraco.W ...
- C# SendMessage用法一二
函数功能:该函数将指定的消息发送到一个或多个窗口.此函数为指定的窗口调用窗口程序,直到窗口程序处理完消息再返回.而函数PostMessage不同,将一个消息寄送到一个线程的消息队列后立即返回. 函数 ...