Teach you how to install mysql database under Linux

My linux environment: RedHat7.3 Enterprise Edition

mysql ready to install: not sure

1. Go to the mysql official website to find information:

  • Baidu: "mysql official website":
  • Open the official website and select "Download":

Choose the version of mysql according to your needs, I can only choose the community version to play.

  • Pull to the Community Edition at the bottom of the interface and click the download link:

The jump page is as follows:

Click on the "MySQL Community Edition server" or "Download" link:

 

  • Select the operating system where mysql will be installed:

  • Select the version of the operating system:

  • Choose a download method:

As you can see here, MySQL can be automatically installed with "yum" in Redhat, or you can download a tar or rpm package to install it.

2. Install MySQL using "yum":

  • Click on the part of area 1 above to automatically jump to the Yum Repository list:

The download interface after clicking download: (here is downloaded to my computer, not on a linux machine, so I use wget to download files on linux...)

Right click->copy link address:

https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm

Download the Yum Rpm file:

  • wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm

This needs to install wget first, otherwise the prompt command cannot be found (if it has been installed, ignore it):

  • yum install wget -y

View file list:

ls -l 

Install the downloaded Yum rpm package:

If the file name is too long, enter a few prefixes first, and then press the tab key:

  • rpm -Uvh mysql80-community-release-el7-1.noarch.rpm

or:

  • yum install mysql80-community-release-el7-1.noarch.rpm -y

Here "-y" is to remove the confirmation process and install it directly.

Select mysql version:

  • yum repolist all | grep mysql

The above list will tell you how many versions are available, and will show whether each version is "disabled" or "enabled". If you want to enable or disable a certain version of mysql, you can use the following command:

sudo yum-config-manager --disable mysql57-comunity

sudo yum-config-manager --enable mysql56-comunity

If you are under root, you don't need sudo.

But you have to install the package where yum-config-manager is located first:

yum install yum-utils -y

If you only want to see the enabled version of mysql, use:

yum repolist enabled | grep mysql

Install the specified version of mysql:

  • yum install mysql-community-server

Because only one version of a type of mysql is enabled, you can directly enter the server type you installed and it will be installed automatically.

Well, I forgot to add the parameter "-y":

Long waiting process:

All right:

Check:

rpm -qa | grep mysql

3. Or use "wget" or "curl" to download MySQL:

In this way, you need to download the tar package yourself, and then execute the installation command, while yum is directly downloaded and installed.

Select the package you want to download and click the download button:

Download:

Right click->copy link address:

https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.11-1.el7.x86_64.rpm-bundle.tar

This is the actual download address. .

No way, I'll just do this stupid way. . .

Download MySQL from the command line under Linux:

wget download the installation package:

  • wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.11-1.el7.x86_64.rpm-bundle.tar

too slow! ! ! !

curl to download the installation package:

  • crul -O -L https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.11-1.el7.x86_64.rpm-bundle.tar

The same as wget above, it is a download. . . too slow. . . .

So everyone directly use yum to install, don't work so hard!

After downloading, use "ls -l" to view a list of all files.

Unzip the mysql archive:

I have already installed it and will not execute it. I will find a screenshot for you, and everyone will write the command like this:

tar -xvf mysql-5.7.11-Linux-glibc2.5-x86_64.tar.gz

4. Create the data directory:

mkdir /usr/local/mysql/data

5. Start the mysql service:

  • Start the mysql service: service mysqld start
  • The el7-based platform can also be started like this: systemctl start mysqld.service
  • Check the service status: service mysqld status
  • The el7-based platform can also be viewed like this: systemctl status mysqld.service

  • Stop the mysql service: service mysqld stop

It's too long, I'll leave the rest for other articles, thank you for reading~~

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325042667&siteId=291194637