When most administrators install MySQL on Linux, the focus is usually on getting the server up and running as quickly as possible. Once the installation completes and the mysqld service starts successfully, the work often shifts to creating databases, users, and application schemas.

However, the first startup of a MySQL server is one of the most important phases in the lifecycle of a database environment.

During initialization, MySQL creates the data directory structure, generates SSL certificates, initializes InnoDB system tablespaces, creates internal system schemas, generates a temporary root password, and prepares the server for normal operations.

Understanding what happens behind the scenes during this process can help DBAs troubleshoot startup issues, validate installations, and better understand the components that make up a MySQL instance.

In this article, I’ll walk through the key activities performed by MySQL during its first startup on a Linux server.

The First Startup Process

After installing MySQL packages, the service is typically started using:

systemctl start mysqld

At first glance, the command appears simple. Behind the scenes, however, MySQL performs several initialization tasks before the server is ready to accept connections.

The process can be visualized as follows:

  1. Install packages
  2. Start mysqld
  3. Initialize the data directory
  4. Generate SSL certificates
  5. Create system schemas
  6. Create the root account
  7. Generate a temporary password
  8. Bring the server online

If any of these steps fail, the startup process may terminate and require investigation using the MySQL error log.

Creating the Data Directory

One of the first tasks performed during initialization is the creation of the MySQL data directory.

By default, the location is:

/var/lib/mysql

This directory becomes the home for all database files, system schemas, logs, certificates, and InnoDB tablespaces.

The location can be verified in the MySQL configuration file:

cat /etc/my.cnf

Example:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysqld.log

Please see below for the terminal output:

[root@mysql-a ~]# cat /etc/my.cnf

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html

[mysqld]

-- output truncated for better visibility

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

[root@mysql-a ~]#

This output confirms the default MySQL data directory, socket location, and error log path used during server initialization.

Initializing InnoDB System Files

After creating the data directory, MySQL initializes the InnoDB storage engine.

Several internal files are created automatically.

Example:

ibdata1
ibtmp1
undo_001
undo_002

These files are critical to InnoDB operations.

ibdata1

The InnoDB system tablespace stores metadata and internal information used by the storage engine.

ibtmp1

The temporary tablespace is used for intermediate operations such as sorting and temporary table processing.

undo_001 and undo_002

Undo tablespaces store information required for transaction rollback and multi-version concurrency control (MVCC).

Many administrators encounter these files immediately after installation but are often unsure of their purpose.

Please see below for the terminal output:

[root@mysql-a ~]# cd /var/lib/mysql
[root@mysql-a mysql]# ls -ltr

total 90568
-rw-r----- 1 mysql mysql       56 Aug 29 19:54 auto.cnf
-rw-r----- 1 mysql mysql  8585216 Aug 29 19:54 #ib_16384_1.dblwr
drwxr-x--- 2 mysql mysql     8192 Aug 29 19:54 performance_schema
-rw------- 1 mysql mysql     1680 Aug 29 19:54 ca-key.pem
-rw-r--r-- 1 mysql mysql     1112 Aug 29 19:54 ca.pem
-rw------- 1 mysql mysql     1676 Aug 29 19:54 server-key.pem
-rw-r--r-- 1 mysql mysql     1112 Aug 29 19:54 server-cert.pem
-rw------- 1 mysql mysql     1676 Aug 29 19:54 client-key.pem
-rw-r--r-- 1 mysql mysql     1112 Aug 29 19:54 client-cert.pem
-rw------- 1 mysql mysql     1676 Aug 29 19:54 private_key.pem
-rw-r--r-- 1 mysql mysql      452 Aug 29 19:54 public_key.pem
drwxr-x--- 2 mysql mysql      143 Aug 29 19:54 mysql
drwxr-x--- 2 mysql mysql       28 Aug 29 19:54 sys
-rw-r----- 1 mysql mysql     5959 Aug 29 19:54 ib_buffer_pool
drwxr-x--- 2 mysql mysql      187 Aug 29 19:54 #innodb_temp
-rw-r----- 1 mysql mysql       16 Aug 29 19:54 binlog.index
-rw------- 1 mysql mysql        5 Aug 29 19:54 mysql.sock.lock
srwxrwxrwx 1 mysql mysql        0 Aug 29 19:54 mysql.sock
drwxr-x--- 2 mysql mysql     4096 Aug 29 19:54 #innodb_redo
-rw-r----- 1 mysql mysql 12582912 Aug 29 19:54 ibtmp1
-rw-r----- 1 mysql mysql 25165824 Aug 29 19:56 mysql.ibd
-rw-r----- 1 mysql mysql 16777216 Aug 29 19:57 undo_001
-rw-r----- 1 mysql mysql 16777216 Aug 29 19:57 undo_002
-rw-r----- 1 mysql mysql   196608 Aug 29 19:57 #ib_16384_0.dblwr
-rw-r----- 1 mysql mysql 12582912 Aug 29 19:57 ibdata1
-rw-r----- 1 mysql mysql      825 Aug 29 19:57 binlog.000001

[root@mysql-a mysql]#

This directory listing shows the core files and folders created during initialization, including InnoDB system files, SSL certificates, internal schemas, and the initial binary log files.

Here is the MySQL installation layout for reference:

Component Location
Client programs and scripts /usr/bin
mysqld server /usr/sbin
Configuration file /etc/my.cnf
Data directory /var/lib/mysql
Error log file /var/log/mysqld.log
secure_file_priv /var/lib/mysql-files
System V init script /etc/init.d/mysql
Systemd service mysqld
Pid file /var/run/mysql/mysqld.pid
Socket /var/lib/mysql/mysql.sock
Keyring directory /var/lib/mysql-keyring
Unix manual pages /usr/share/man
Include files /usr/include/mysql
Libraries /usr/lib/mysql
Miscellaneous support files /usr/share/mysql

This table summarizes the default MySQL installation paths for server binaries, configuration, runtime files, libraries, and supporting components.

Generating SSL Certificates

Modern MySQL installations automatically generate SSL certificates during initialization.

Within the data directory, you’ll typically find:

ca.pem
server-cert.pem
server-key.pem
client-cert.pem
client-key.pem

These files enable encrypted client-server communication and support secure connections without requiring manual certificate creation.

To verify the certificates:

ls -l *.pem

For development environments, the automatically generated certificates are usually sufficient. Production environments often replace them with certificates issued by an internal Certificate Authority (CA).

Creating the System Schemas

Every MySQL installation includes several internal schemas.

These databases are created automatically during initialization.

Verify them using:

SHOW DATABASES;

Expected output:

information_schema
mysql
performance_schema
sys

Let’s briefly examine their purpose.

information_schema

Provides metadata about database objects such as tables, columns, indexes, and privileges.

mysql

Contains user accounts, grants, roles, and server metadata.

performance_schema

Collects performance instrumentation data used for troubleshooting and performance analysis.

sys

Provides DBA-friendly views built on top of the Performance Schema.

These schemas form the foundation of MySQL administration and monitoring.

Please see below for the terminal output:

[root@mysql-a ~]# su - mysql

Last login: Thu Aug 31 14:23:39 CDT 2023 on pts/0

-bash-4.2$ whoami

mysql

-bash-4.2$ mysql -u root -p

Enter password:

mysql> show databases;

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+

4 rows in set (0.00 sec)

This output confirms that MySQL created the core internal schemas required for metadata, user management, instrumentation, and administrative views.

Creating the Root Account

Another critical initialization task is creating the MySQL root account.

By default, MySQL creates:

root@localhost

This account is intended for administrative operations and initially requires the temporary password generated during startup.

Unlike older MySQL releases, remote root access is not enabled by default.

This provides an additional layer of security for new installations.

Generating the Temporary Root Password

During initialization, MySQL generates a random temporary password for the root account.

The password is written to the MySQL error log.

Retrieve it using:

grep 'temporary password' /var/log/mysqld.log

Example:

A temporary password is generated for root@localhost

This password is required for the first login and must be changed before normal administrative operations can continue.

Please see below for the terminal output:

[root@mysql-a ~]# sudo grep 'temporary password' /var/log/mysqld.log

2023-08-19T20:03:35.705456Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: XXXXXXXX

This log entry confirms that MySQL generated the initial administrative credential during startup. The temporary password should be used only for first login and changed immediately.

Initializing Binary Logging

If binary logging is enabled, MySQL also creates the initial binary log files during startup.

Example:

binlog.000001
binlog.index

Binary logs record database changes and play a critical role in:

  • Replication
  • Point-in-time recovery
  • Auditing database activity

Although many administrators associate binary logging with replication, it is equally important for backup and recovery strategies.

Reviewing the Error Log

If initialization fails, the first place I investigate is the MySQL error log.

The default location is:

/var/log/mysqld.log

Useful commands include:

tail -50 /var/log/mysqld.log

or

grep ERROR /var/log/mysqld.log

The error log often provides immediate insight into:

  • Permission problems
  • Filesystem issues
  • Configuration errors
  • Port conflicts
  • InnoDB initialization failures

Developing a habit of reviewing the error log after installation can save considerable troubleshooting time later.

Common Initialization Issues

Some of the most common startup problems I encounter include:

Incorrect File Permissions

The MySQL service account must have ownership of the data directory.

Existing Data Directory

Attempting to initialize a server on top of an existing data directory can cause startup failures.

Port Conflicts

Another database service may already be listening on port 3306.

Configuration Errors

Invalid parameters in my.cnf can prevent successful startup.

Fortunately, most of these issues are quickly identified by reviewing the error log.

Final Thoughts

The first startup of a MySQL server involves much more than simply launching a database process.

During initialization, MySQL creates the foundation of the database environment, including system schemas, InnoDB tablespaces, SSL certificates, administrative accounts, and logging structures.

Understanding these components helps administrators troubleshoot installation issues more effectively and provides valuable insight into how MySQL operates internally.

The next time you install MySQL, spend a few minutes exploring the files and schemas that were created automatically. Those observations become increasingly valuable as you move into backup and recovery, replication, performance tuning, and high availability deployments.


<
Previous Post
Installing MySQL Community Server on Oracle Linux Using the MySQL Repository
>
Next Post
Essential MySQL Command-Line Utilities Every DBA Should Know - Part 1