MySQL Server Socket Connection on CentOS

This section provides a tutorial example on how to use the Socket Connection for client programs from the same host as the MySQL 8 Server on CentOS 8 systems.

MySQL server supports 2 types of connections from client programs:

Socket Connection works under the following rules:

1. By default, the Socket Connection is turned on for MySQL 8 server.

2. Socket Connection is represented with socket files on CentOS system with "mysqlx_socket" and "socket" variables for their locations:

mysql> show variables like '%socket';
| Variable_name | Value                      |
| mysqlx_socket | /var/lib/mysql/mysqlx.sock |
| socket        | /var/lib/mysql/mysql.sock  |

3. Users must be created with "localhost" as host named to use the Socket Connection. For example, "root" and "herong" are users who can use the Socket Connection based on the mysql.user records:

mysql> select user, host from mysql.user;
| user             | host      |
| mysql.infoschema | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
| root             | localhost |
| herong           | localhost |

4. Client programs must use "localhost" as the host name to use the Socket Connection. For example, the following PHP statement will connect to the MySQL server using the Socket Connection:

$conn = mysqli_connect("localhost", 'herong', 'TopSecret');

5. MySQL client tools connect to the SQL server use the Socket Connection with the default "-h localhost" option. See the example below:

herong$ mysql -u herong -p
Enter password: junk<Enter>

ERROR 1045 (28000): Access denied for user 'herong'@'localhost' ...

Socket Connection is more secure. But it only allows connections from the same host as the MySQL server. To allow connections from a remote host, you have to use the TCP/IP connection as shown in the next tutorial.

Table of Contents

 About This Book

 Introduction to Linux Systems

 Process Management

 Files and Directories

 Running Apache HTTP Server (httpd) on Linux Systems

 Running Apache Tomcat on Linux Systems

 Running PHP Scripts on Linux Systems

Running MySQL Database Server on Linux Systems

 Install MySQL Database Server on CentOS

 Manage MySQL Server 'mysqld' on CentOS

 Set MySQL Server "root" Password on CentOS

 MySQL Server File Locations on CentOS

 MySQL Server Data Backups on CentOS

 MySQL Server Log Files on CentOS

MySQL Server Socket Connection on CentOS

 MySQL Server TCP/IP Connection on CentOS

 Open Firewall for MySQL Server on CentOS

 "Server sent charset unknown to the client" Error

 Performance of Inserting Integers to MySQL Database

 Performance Comparison of Inserting Integers vs. Strings

 Running Python Scripts on Linux Systems

 Conda - Environment and Package Manager

 GCC - C/C++ Compiler

 OpenJDK - Open-Source JDK

 Graphics Environments on Linux

 SquirrelMail - Webmail in PHP

 Tools and Utilities


 Full Version in PDF/EPUB