This is the seventh day of my participation in the More text Challenge. For details, see more text Challenge

About the author:

LuciferLiu is a member of China DBA alliance (ACDU). Currently, I am working as Oracle DBA and used to be engaged in the development of Oracle database, mainly serving the manufacturing, auto finance and other industries. Now he has Oracle OCP and OceanBase OBCA certifications. He is good at Oracle database operation and maintenance development, backup and recovery, installation and migration, Linux automatic operation and maintenance script writing, etc.

I. Linux server installation

Centos, Redhat, and Oracle Linux can be installed on the Linux server.

This article is configured asRedhat 7.9 x86_64.The memory of 2 g.Hard drive 50 g.



For details about how to install a Linux OS, see:

How can Windows hosts play with virtual Machine Linux installations, just read this article

Here are three steps to installing Linux on MacOS

Mysql installation media download

Download address:MySQL Product Archives

Select version:A classic 5.7.20 linux-Generic x86-64



After downloading, the installation package is as follows:Mysql - 5.7.20 - Linux - glibc2.12 - x86_64. Tar. GzTo a folder on the Linux server using the FTP tool.

Install mysql

Installing MySQL on Unix/Linux Using Generic Binaries

Now that the above preparations are done, connect to the Linux host:SSH [email protected]
1. Check the installation medium

2. Decompress the installation media
CD /soft tar -xvf mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz Mysql - mv 5.7.20 - Linux - glibc2.12 - x86_64 mysqlCopy the code

3. Create users and groups
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
Copy the code

4. Create related directories
mkdir -p /data/mysql
chown -R mysql:mysql /data
chown -R mysql:mysql /soft
chmod 750 /data
Copy the code

5. Configure environment variables
Cat <<EOF>> /root/.bash_profile export PATH=\$PATH:/soft/mysql/bin EOF ## Effective environment variable source /root/.bash_profileCopy the code

6. Install dependency packages
# # mount mirror source mount/dev/cdrom/MNT # # configuration yum source cat < < EOF > > / etc/yum repos. D/local. '[local] name = local baseurl = file:///mnt Gpgcheck =0 enabled=1 EOF ## yum install -y libaioCopy the code

Uninstall mariadb and mysql

Check whether the system is installed mysql: RPM – qa | grep mysql, because I am so no minimize installation. If there is a mandatory uninstall: RPM -e — nodeps $(RPM – qa | grep mysql)

Check whether the system is installed mariadb RPM – qa | grep mariadb if there is a mandatory uninstall: RPM -e — nodeps $(RPM – qa | grep mariadb), unloading success here.

Initialize mysql

Initialize the mysql database by running the following command:

mysqld --initialize --user=mysql --basedir=/soft/mysql --datadir=/data/mysql/

Parameters:--basedirUnzip directory for mysql,--datadirDirectory for storing mysql data.

The initial password for user root is displayed:yhfvt_rP,24M

Configure the my.cnf file
cat <<EOF>/etc/my.cnf [mysqld] user=mysql basedir=/soft/mysql datadir=/data/mysql server_id=6 port=3306 Socket =/ TMP /mysql.sock Prompt =lucifer [\\\\d]> EOFCopy the code



Mysql > Start mysql service:/soft/mysql/support-files/mysql.server start

Mysql service can also be configured to start on startup:

Linux 6&7 common configuration:

cp /soft/mysql/support-files/mysql.server /etc/init.d/mysqld



You can use it after configuring itserver mysqld startStart the mysql service.

Linux7 Configuration mode:

Mysqld. service:

cat <>/usr/lib/systemd/system/mysqld.service

[Unit]

Description=MySQL Server

Documentation=man:mysqld(8)

Documentation=Dev.mysql.com/doc/refman/…

After=network.target

After=syslog.target

[Install]

WantedBy=multi-user.target

[Service]

User=mysql

Group=mysql

ExecStart=/soft/mysql/bin/mysqld –defaults-file=/etc/my.cnf

LimitNOFILE = 5000

EOF



You can use it after configuring itsystemctl start mysqldStart the mysql service.



Try connecting to the mysql database:mysql -uroot -pyhfvt_rP,24M

Change the initial password of user root because the initial password is not easy to remember.

Mysqladmin:Detail of the mysqladmin command

Reset root password:mysqladmin -uroot -pyhfvt_rP,24M password mysql



Connect to mysql database with new password:mysql -uroot -pmysql



View the current created database:



Mysql > select * from user where user = ‘mysql’;



If you think the article is helpful to you, like, collect, follow, comment, one key four connect support, your support is the biggest motivation for my creation, thank you ~

Ink wheel: Lucifer think before you act CSDN: Lucifer think before you act wechat public number: Lucifer think before you act