NOTE

1.4 MySQL Installation and Configuration

1. MySQL Installation Steps 1.1. Install 1.2. Start 1.3. Set the root Password 1.4. Create a User 1.5. Change the Listening Port 2. Default Configuration 2.1. Print Default Configuration Information 2.2. Configuration File Locations 2.3. Basic Configuration 2.3.1. log-bin Mainly used for primary-replica replication 2.3.2. log-error

DatabasesCreated Updated 1 min readhistorical

This is a historical learning note and may contain outdated or incomplete understanding.

1. MySQL Installation Steps

1.1. Install

sudo apt install mysql-server

1.2. Start

sudo service mysql start

1.3. Set the root Password

sudo mysql_secure_installation

1.4. Create a User

CREATE USER '<example-user>'@'localhost' IDENTIFIED BY '<example-password>';
GRANT ALL PRIVILEGES ON *.* TO '<example-user>'@'localhost' WITH GRANT OPTION;

1.5. Change the Listening Port

vim  /etc/mysql/mysql.conf.d/mysqld.cnf
#bind-address:127.0.0.1

2. Default Configuration

2.1. Print Default Configuration Information

mysqld --help --verbose

2.2. Configuration File Locations

/etc/my.cnf /etc/my.cnf.d/ ~/.my.cnf

2.3. Basic Configuration

2.3.1. log-bin

Mainly used for primary-replica replication.

log-bin=/var/lib/mysql/mysql-bin

2.3.2. log-error

Records error information.

log-err=/var/lib/mysql/mysql-err

2.4. Query Log

Records slow-query information.

2.5. Data Files

Default location: /var/lib/mysql frm files store table structures. myd stores table data. myi stores table indexes.

3. Installation Directory

  • mysqld
    • The mysqld executable represents the MySQL server program. Running this executable can directly start a server process.
  • mysqld_safe
    • mysqld_safe is a startup script. It indirectly invokes mysqld and also starts another monitoring process.
    • If the server process crashes, the monitoring process can help restart it.
    • In addition, when mysqld_safe is used to start the server program, it redirects the server program’s error information and other diagnostic information to a file, producing an error log so that the cause of an error can be found more conveniently.
  • mysql.server
    • mysql.server is also a startup script. It indirectly invokes mysqld_safe. When invoking mysql.server, specify the start argument after it to start the server program.
  • mysqld_multi
    • Command for multiple instances on one machine.

4. References

Discussion

Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub