Home Database Mysql Tutorial mysql.sock的作用_MySQL

mysql.sock的作用_MySQL

May 30, 2016 pm 05:10 PM
effect

 

1、在编译安装mysql的时候,会将mysql的配置文件复制到/etc/my.conf中:

 

[root@Web-lnmp02 mysql]# cp support-files/my-small.cnf /etc/my.cnf 将配置模板复制到mysql的配置文件

cp:是否覆盖"/etc/my.cnf"? y

 

2、可以通过查看/etc/my.conf查看mysql.sock的目录位置:

 

[root@mysql ~]# cat /etc/my.cnf 
[mysqld]
port            = 3306
socket          = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 16K
max_allowed_packet = 1M
table_open_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 128K
Copy after login

3、在登录mysql的时候可以加上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 5
Server 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 its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> 
Copy after login

 

Mysql有两种连接方式: 

 

(1),TCP/IP 

 

(2),socket 

 

对mysql.sock来说,其作用是程序与mysqlserver处于同一台机器,发起本地连接时可用。 

 

例如你无须定义连接host的具体IP地址,只要为空或localhost就可以。 

 

在此种情况下,即使你改变mysql的外部port也是一样可能正常连接。 

 

因为你在my.ini中或my.cnf中改变端口后,mysql.sock是随每一次 mysql server启动生成的。已经根据你在更改完my.cnf后重启mysql时重新生成了一次,信息已跟着变更。 

 

那么对于外部连接,必须是要变更port才能连接的。 

 

linux下安装mysql连接的时候经常回提示说找不到mysql.sock文件,解决办法很简单: 

 

如果是新安装的mysql,提示找不到文件,就搜索下,指定正确的位置。 

 

如果mysql.sock文件误删的话,就需要重启mysql服务,如果重启成功的话会在datadir目录下面生成mysql.sock 到时候指定即可。 

 

如果还不行就选择用TCP连接方式连接就行了,其实windows下还支持管道连接方式。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

The functions and uses of touch keyboard in win11 The functions and uses of touch keyboard in win11 Jan 03, 2024 pm 04:40 PM

When we browse the win11 settings, we may find that there is a touch keyboard setting, but our screen does not support touch screen, so what is the use of this win11 touch keyboard? In fact, it is an on-screen keyboard. The functions of the win11 touch keyboard: 1. The win11 touch keyboard is actually an "on-screen keyboard" 2. It can simulate a real keyboard and use the keyboard by clicking. 3. When we don’t have a keyboard or the keyboard is broken, we can use it to type. 4. Win11 provides a wealth of personalized options for the touch keyboard. 5. It includes various colors and themes, allowing users to freely switch their favorite styles. 6. Click the "gear" in the upper left corner to modify the keyboard layout, handwriting and other input methods.

Analysis of the function and principle of nohup Analysis of the function and principle of nohup Mar 25, 2024 pm 03:24 PM

Analysis of the role and principle of nohup In Unix and Unix-like operating systems, nohup is a commonly used command that is used to run commands in the background. Even if the user exits the current session or closes the terminal window, the command can still continue to be executed. In this article, we will analyze the function and principle of the nohup command in detail. 1. The role of nohup: Running commands in the background: Through the nohup command, we can let long-running commands continue to execute in the background without being affected by the user exiting the terminal session. This needs to be run

What is a Bluetooth adapter used for? What is a Bluetooth adapter used for? Feb 19, 2024 pm 05:22 PM

What does a Bluetooth adapter do? With the continuous development of science and technology, wireless communication technology has also been rapidly developed and popularized. Among them, Bluetooth technology, as a short-distance wireless communication technology, is widely used in data transmission and connection between various devices. The Bluetooth adapter plays a vital role as an important device that supports Bluetooth communication. A Bluetooth adapter is a device that can turn a non-Bluetooth device into a device that supports Bluetooth communication. It realizes wireless connection and data transmission between devices by converting wireless signals into Bluetooth signals. Bluetooth adapter

Understand the role and usage of Linux DTS Understand the role and usage of Linux DTS Mar 01, 2024 am 10:42 AM

Understand the role and usage of LinuxDTS In the development of embedded Linux systems, Device Tree (DeviceTree, DTS for short) is a data structure that describes hardware devices and their connection relationships and attributes in the system. The device tree enables the Linux kernel to run flexibly on different hardware platforms without modifying the kernel. In this article, the function and usage of LinuxDTS will be introduced, and specific code examples will be provided to help readers better understand. 1. The role of device tree device tree

Explore the importance and role of define function in PHP Explore the importance and role of define function in PHP Mar 19, 2024 pm 12:12 PM

The importance and role of the define function in PHP 1. Basic introduction to the define function In PHP, the define function is a key function used to define constants. Constants will not change their values ​​during the running of the program. Constants defined using the define function can be accessed throughout the script and are global. 2. The syntax of define function The basic syntax of define function is as follows: define("constant name","constant value&qu

Learn more about Gunicorn's fundamentals and features Learn more about Gunicorn's fundamentals and features Jan 03, 2024 am 08:41 AM

Basic concepts and functions of Gunicorn Gunicorn is a tool for running WSGI servers in Python web applications. WSGI (Web Server Gateway Interface) is a specification defined by the Python language and is used to define the communication interface between web servers and web applications. Gunicorn enables Python web applications to be deployed and run in production environments by implementing the WSGI specification. The function of Gunicorn is to

What is PHP used for? Explore the role and functions of PHP What is PHP used for? Explore the role and functions of PHP Mar 24, 2024 am 11:39 AM

PHP is a server-side scripting language widely used in web development. Its main function is to generate dynamic web content. When combined with HTML, it can create rich and colorful web pages. PHP is powerful. It can perform various database operations, file operations, form processing and other tasks, providing powerful interactivity and functionality for websites. In the following articles, we will further explore the role and functions of PHP, with detailed code examples. First, let’s take a look at a common use of PHP: dynamic web page generation: P

Detailed explanation of usage scenarios and functions of volatile keyword in Java Detailed explanation of usage scenarios and functions of volatile keyword in Java Jan 30, 2024 am 10:01 AM

Detailed explanation of the role and application scenarios of the volatile keyword in Java 1. The role of the volatile keyword In Java, the volatile keyword is used to identify a variable that is visible between multiple threads, that is, to ensure visibility. Specifically, when a variable is declared volatile, any modifications to the variable are immediately known to other threads. 2. Application scenarios of the volatile keyword The status flag volatile keyword is suitable for some status flag scenarios, such as a

See all articles