Summary of the process for installing a mysql database on a CentOS-6.9-x86_64-minimal,
1. Create a mysql user and a mysql group.
# Useradd-s/bin/nologin-M mysql
Check whether the creation is successful.
# Id mysql
2. Extract the mysql binary package to the/usr/local/directory.
# Cd/usr/local/
# Tar-zxvf mysql-5.7.20-linux-glibc2.5-x86_64.tar.gz (different versions)
Rename the decompressed folder for future operations.
# Mv mysql-5.7.20-linux-glibc2.5-x86_64 mysql (change file name to mysql)
# Cd mysql
# Chowm-R mysql. mysql.
# This step is very important. Do not forget to modify the permission.
# Check whether the permission is modified.
# Ls-l (or ll)
3. initialize the database.
The support-files in the Mysql folder contains the mysql sample configuration file and Service Startup Script.
Bin stores important mysql commands (used for database initialization, backup, replication, etc)
# Bin/mysqld -- initialize -- user = mysql -- datadir =/usr/local/mysql/data (remember that the password is "A temporary password is generated for root @ localhost: t3c2O26 "T3c2O26") if initialization fails, enter yum-y install numactl
-- Initialize is used to initialize the database and generate a random initial password. The password is printed on the screen. You can also view the password in the data directory.
-- Datadir is used to store database directories (Data Directories and log directories in the production environment must be stored on separate disks ).
# Cp support-files/mysql. server/etc/init. d/mysqld
# Use mysql as a daemon.
4. Modify and edit the mysql configuration file.
# Vi/etc/my. cnf
Data:
Datadir =/usr/local/mysql/data/
Port = 3306
Socket =/tmp/mysql. sock
Key_buffer_size = 16 M
Max_allowed_packet = 8 M
This is my configuration file, which only provides the simplest configuration. You can configure the relevant parameters as needed.
5. Start the database
# Service mysqld start
# SUCCESS indicates that the startup is successful.
View the server port status.
# Netstat-tulnp
Use the command line to enter mysql.
#/Usr/local/mysql/bin/mysql-u root-p
Go to the database and change the password
# Set password = PASSWORD ('123 ');