Reported: Can ' t connect to local MySQL server through socket '/var/lib/mysql/mysql.sock ' (2) error.

Source: Internet
Author: User

Workaround:

1. Check if MySQL permissions are a problem (default installation is yum-y install MySQL)

Go to the/etc/rc.d/init.d/directory

[Email protected] init.d]# mysqld status
2018-06-11 15:20:47 0 [Warning] TIMESTAMP with implicit DEFAULT value is Depreca ted. Please use the--EXPLICIT_DEFAULTS_FOR_TIMESTAMP server option (see Documentati in for more details).
2018-06-11 15:20:47 0 [Note] mysqld (mysqld 5.6.40) starting as Process 12917.. .
2018-06-11 15:20:47 12917 [ERROR] Fatal error:please read "Security" section of the manual-find out how to run mysqld As root!

2018-06-11 15:20:47 12917 [ERROR] Aborting

2018-06-11 15:20:47 12917 [Note] Binlog End
2018-06-11 15:20:47 12917 [Note] Mysqld:shutdown complete

The first of these errors is

2018-06-11 15:20:47 12917 [ERROR] Fatal error:please read "Security" section of the manual-find out how to run mysqld As root!

This is because MySQL, for security purposes, does not want the root user to start MySQL directly.

So you can add user=mysql to the/etc/my.cnf to specify the MySQL user

--------------------------------------------------------------------

[Mysqld]

User=mysql

--------------------------------------------------------------------

[[email protected] search]# MySQL
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 3
Server version:5.6.40 MySQL Community Server (GPL)

Copyright (c), 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

Mysql>

You can see that MySQL started successfully.

Reported: Can ' t connect to local MySQL server through socket '/var/lib/mysql/mysql.sock ' (2) error.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.