Mysql. sock role _ MySQL

Source: Internet
Author: User
1. during mysql compilation and installation, the mysql configuration file will be copied to etcmy. in conf: [root @ Web-lnmp02mysql] # The cpsupport-filesmy-small.cnfetcmy.cnf copies the configuration template to the mysql configuration file cp: whether to overwrite etcmy. cnf? 1. during mysql compilation and installation, the mysql configuration file will be copied to/etc/my. conf:

[Root @ Web-lnmp02 mysql] # cp support-files/my-small.cnf/etc/my. cnf copy the configuration template to the mysql profile

Cp: overwrite "/etc/my. cnf "? Y

2. you can view the directory location of mysql. sock through/etc/my. conf:

[root@mysql ~]# cat /etc/my.cnf [mysqld]port            = 3306socket          = /tmp/mysql.sockskip-external-lockingkey_buffer_size = 16Kmax_allowed_packet = 1Mtable_open_cache = 4sort_buffer_size = 64Kread_buffer_size = 256Kread_rnd_buffer_size = 256Knet_buffer_length = 2Kthread_stack = 128K

3. when logging on to mysql, you can add mysql. sock:

[root@mysql ~]# mysql -u root -poldboy123 -S /tmp/mysql.sock Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 5Server version: 5.5.32 MySQL Community Server (GPL)Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> 

Mysql has two connection methods:

(1), TCP/IP

(2), socket

For mysql. sock, the function is that the program is on the same machine as mysqlserver and can be used to initiate a local connection.

For example, you do not need to define the specific IP address to connect to the host, as long as it is null or localhost.

In this case, even if you change the external port of mysql, the connection is normal.

Because mysql. sock is generated with every mysql server startup after you change the port in my. ini or my. cnf. After you have changed my. cnf and restarted mysql, the information has been changed.

For external connections, you must change the port to connect.

When installing mysql connections in linux, I often return a prompt saying that the mysql. sock file cannot be found. The solution is simple:

If the newly installed mysql file is not found, search for the file and specify the correct location.

If the mysql. sock file is deleted by mistake, you need to restart the mysql service. if the restart succeeds, mysql. sock will be generated under the datadir directory and specified at that time.

If the connection fails, you can use the TCP connection method. In fact, the MPs queue connection mode is also supported in windows.

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.