MySQL installation tutorial under Linux centos7 environment

MySQL installation tutorial under Linux centos7 environment

Detailed introduction to the steps of installing MySQL in Linux centos7 environment

Install MySQL

MySQL has two differences from Windows

1) Save my.ini to /etc/my.ini

2) User permissions, executed by a single user

1. Check whether MySQL has been installed before, use the following command:

rpm –qa | grep -i mysql

If the following packages are displayed, it means that mysql has been installed

mysql-4.1.12-3.RHEL4.1

mysqlclient10-3.23.58-4.RHEL4.1

2. Download the mysql decompression package

mysql-5.7.17-linux-glibc2.5-x86_64.tar (download from http://mirrors.sohu.com)

Website: http://mirrors.sohu.com/mysql/MySQL-5.7/

You can also download it under the Linux operating system by entering the following command

wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

Create a directory software to store the MySQL package we will download later. Go to the directory and enter the command: cd /software

After the download is complete, you will see an additional MySQL installation package file in the software directory.

3. Create a user and mysql directory

1. groupadd mysql #Create a mysql group

2. useradd -r -g mysqlmysql #Create mysql user and put the user into mysql group

3. passwd mysql #Set a password for the mysql user

4. Unzip the MySQL installation package

1. Move the tar.gz package to the /usr/local directory and enter the command

mv /software/MySQL/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz/usr/local

2. Unzip the tar.gz package

First go to the /usr/local directory and enter the command cd /usr/local

Decompression command tarzxvfmysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

Enter the command to view the directory:

You will find an additional directory mysql-5.7.17-linux-glibc2.5-x86_64

Note: There is no data directory, the my.ini file is in the support-files directory

3. Change the directory name to /usr/local/mysql

(This is the default installation directory for MySQL under Linux)

Rename the unzipped file to mysql

Enter the command: mv mysql-5.7.17-linux-glibc2.5-x86_64 mysql

5. Configure related startup configuration files

First, go to the support-files/file directory

Enter the command: cd support-files/

1. Copy my.cnf to /etc/my.cnf (automatically read when mysql starts)

Enter the command cpmy-default.cnf /etc/my.cnf

2. Solve the garbled problem

Enter the command: vi /etc/my.cnf (enter editable state)

Change:

[mysql]

default-character-set=utf8 (to solve the problem of garbled characters on the client side)

[mysqld]

default-storage-engine=INNODB

character_set_server=utf8 (to solve the garbled character problem on the server side)

3. Copy mysql.server to the /etc/init.d/ directory [the purpose is to achieve the automatic execution effect of mysqld -install at startup]

Enter the command cp mysql.server /etc/init.d/mysql (mysql is the service name)

Note: The /etc/init.d/ directory is equivalent to the registry HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services, which records those services

4. Modify /etc/init.d/mysql parameters

Enter the command vi /etc/init.d/mysql

Give two directory locations

basedir=/usr/local/mysql

datadir=/usr/local/mysql/data

5. Change the owner of the directory /usr/local/mysql

Enter the command chown -R mysql:mysql /usr/local/mysql/

6. Initialize the mysql database

1. Initialize mysql

mysql_install_db (old version method)

New version: Initialization

Enter the command ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

A data directory is generated, indicating that the database has been initialized successfully

And the root user of mysql generates a temporary password: (record the temporary password XXX)

2. Encrypt the database

Enter the command ./mysql_ssl_rsa_setup --datadir=/usr/local/mysql/data

3. Start mysql

Enter the command ./mysqld_safe --user=mysql & (& means submit to the background to run the mysql service)

7. Enter the client

1. Login

Enter the command ./mysql -uroot -p

Then enter your temporary password

2. Change password

Enter the command set password=password('xxxx')

8. Window remote access to Linux virtual machine mysql

Let's take a look at the database structure first

1. Turn off the firewall (or open a port to the firewall) so that window can connect

Enter the command systemctl stop firewalld.service

2. Authorize Windows

Enter the command mysql>grant all privileges on *.* toroot@'%' identified by '123456';

mysql>use mysql;
mysql>select host,user from user; 

[One more remote login user record]

mysql>flush privileges;

3. Remotely connect to the database, or restart (init 6).

Enter the command: mysql –hIP address-uroot -p123456

9. Set the MySQL service to start automatically at boot

1. Add mysql service

Enter the command chkconfig --add mysql [mysqld -install]

2. Set the mysql service to automatic

Enter the command chkconfig mysql on

3. Restart and check

init 6

ps –ef | grep mysql

10. Set path

Enter the command vi /etc/profile

Enter the command exportPATH=$JAVA_HOME/bin:/usr/local/mysql/bin:$PATH

After configuring the mysql environment variables, we no longer need to go to the /usr/local/mysql/bin directory to log in to mysql in the future. Now we can log in to mysql in any directory

At this point we have successfully installed MySQL in the Linux centos7 environment.

Thank you all for your support!

Wonderful topic sharing:

MySQL different versions installation tutorial

MySQL 5.6 installation tutorials for various versions

MySQL 5.7 installation tutorials for various versions

mysql8.0 installation tutorials for various versions

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Tutorial on installing lnmp using yum on centos7 (linux+nginx+php7.1+mysql5.7)
  • Detailed tutorial on installing Mysql5.7.19 on Centos7 under Linux
  • Linux CentOS6.5 yum install mysql5.6
  • Linux CentOS MySQL 5.7.18 5.7.X Installation Tutorial
  • Detailed explanation of installing mysql 5.7.16 linux glibc2.5 x86 64 in CentOS 6.5 (recommended)
  • How to install mysql source package in Linux CentOS6.6 system
  • Tutorial on how to build and install linux+apache+mysql+php environment with yum under centos
  • How to build and install linux+apache+mysql+php environment with yum under centos
  • Detailed tutorial on installing MySQL 5.7.11 for Linux Generic binary version in CentOS 7 via command line
  • CentOS 6.3 source code installation LAMP (Linux + Apache + Mysql + Php) operating environment steps
  • Tutorial on binary compilation and installation of MySql centos7 under Linux

<<:  Detailed explanation of WordPress multi-site configuration under Nginx environment

>>:  Let's deeply understand the event object in js

Recommend

Detailed tutorial on configuring local yum source in CentOS8

The centos8 distribution is released through the ...

How to use the vue timeline component

This article example shares the specific implemen...

jQuery achieves breathing carousel effect

This article shares the specific code of jQuery t...

Solution to the problem that Java cannot connect to MySQL 8.0

This article shares a collection of Java problems...

Details of using Vue slot

Table of contents 1. Why use slots? 1.1 slot 1.2 ...

How to represent various MOUSE shapes

<a href="http://" style="cursor...

The whole process of realizing website internationalization using Vite2 and Vue3

Table of contents Preface Install vue-i18n Config...

How to install docker on Linux system and log in to docker container through ssh

Note: I use Centos to install docker Step 1: Inst...

Methods for optimizing Oracle database with large memory pages in Linux

Preface PC Server has developed to this day and h...

Flex layout achieves fixed number of rows per line + adaptive layout

This article introduces the flex layout to achiev...

Pay attention to the use of HTML tags in web page creation

HTML has attempted to move away from presentation...

mysql 5.7.18 winx64 free installation configuration method

1. Download 2. Decompression 3. Add the path envi...

JavaScript - Using slots in Vue: slot

Table of contents Using slots in Vue: slot Scoped...