设为首页 加入收藏

TOP

Can’t connect to MySQL Server实例解析(二)
2018-06-18 14:24:19 】 浏览:341
Tags:Can connect MySQL Server 实例 解析
d:

I have seen some cases; socket file is missing for no reason. In this case, connect with TCP / IP protocol to restart the service. Socket, file cannot be created as plain empty file manually. The file should be created by server.

The worst part is you cannot shutdown the server. While stopping the server, it will look for socket file and if it not exists, it will through the socket file missing error. So the alternative method should be as follows:

To shutdown mysql server : mysqladmin –h 127.0.0.1 –protocol=tcp –u root –p shutdownTo login to MySQL server : mysql –h 127.0.0.1 –protocol=tcp –u root –p

Reason 3:Security Enhanced Linux is protecting mysqld process.

Workaround 3:Security Enhanced Linux (SELinux) is a Linux feature that provides mechanism for supporting access control security policies.

In simple words, it does not allow MySQL to access other directories and ports apart from pre-configured access objects. It means, by default, MySQL is configured to access/var/lib/mysql,but when you configured data directory and socket files to different folders, it does not permit access.

You can disable the SELinux protection for mysqld process. This you can done by:

To set SELinux into permissive mode : Setenforce 0 (It will allow but show warnings!)

This settings is applicable still the next server restart. In order to permanently disable the SELinux (private networks), edit the configuration as follows:

To edit the SELinux configuration file : vi /etc/selinux/configTo disable the SELinux protection : SELINUX=disabled (restart required!)

If you wish to configure SELinux protection for mysqld process with proper privileges (production environment), you can referthis pagefor complete details.

Reason 4:

MySQL server is bound to single address (bind_address)

Workaround 4:

To edit bind_address variable : vi /etc/my.cnfTo change bind_address : bind_address=0.0.0.0.0

Here, the problem is, sometimes, by default MySQL bind_address variable is set to localhost or some IP address. When you try to connect MySQL server from other hosts, MySQL does not allow, and provides the error message, since MySQL service is bound to only that bind_address value.

By changing bind_address value into 0.0.0.0 will accept connections from all server hosts.

Reason 5:Firewall blocking MySQL port:

Workaround 5:If the firewall is blocking MySQL port 3306, you can open the port on host machine to fix this issue.

sudo iptables -I INPUT -p tcp --dport 3306 -j ACCEPT

sudo service iptables save

Note: The firewall rules for Windows and latest version of CentOS may vary, use accordingly.

Reason 6:Access restricted to the server hosts.

Workaround 6:There is a possibility that access restricted to server. You can allow access to server by editing the host.allow (Linux) / hosts (Windows file)

To change in Linux : vi /etc/host.allowTo change in Windows : %windows%\system32\drivers\etcTo allow access from all hosts : mysqld: ALL: allow (This is not best practice to allow all – allow only the web server / client hosts allow)

Note: See the TCP wrapper for more details (if you are interested!!!).

Other Possible Reasons:

Incorrect host name / IP address – verify you are giving correct IP address / hostname.The user may not access to database - give access in MySQL using GRANT command.The MySQL variable old_passwords = 1, old_password() is deprecated in MySQL 5.7. It is hashing method to store MySQL password. Setting this variable to 0 will allow you connect MySQL. (See more about this here)The mysqld service unab

首页 上一页 1 2 3 下一页 尾页 2/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇oracle存储过程selectinto没有查.. 下一篇JDBC连接MySQL报错Unknownsystemv..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目