MySQL Server Socket Connection on CentOS

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

 Cockpit - Web Portal for Administrator

 Process Management

 Files and Directories

 Users and Groups

 File Systems

 Block Devices and Partitions

 LVM (Logical Volume Manager)

 Installing CentOS

 SELinux - Security-Enhanced Linux

 Network Connection on CentOS

 Software Package Manager on CentOS - DNF and YUM

 Running Apache Web Server (httpd) 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

 vsftpd - Very Secure FTP Daemon

 Postfix - Mail Transport Agent (MTA)

 Dovecot - IMAP and POP3 Server

 Email Client Tools - Mail User Agents (MUA)

 LDAP (Lightweight Directory Access Protocol)

 GCC - C/C++ Compiler

 Conda - Environment and Package Manager

 Tools and Utilities

 Administrative Tasks

 References

 Full Version in PDF/EPUB