Installing MySQL in CentOS 7

Anonim

Installing MySQL in CentOS 7

MySQL is rightfully considered one of the best database management systems, therefore is actively used by both professionals and lovers in working with websites and various applications. For the correct operation of this tool, it will have to be installed in the operating system and set the correct configuration, pushing out of the existing servers and additional components. Today we want to show exactly how this process is carried out on computers running CentOS 7.

Install MySQL in CentOS 7

The information in our current article will be divided into stages so that each user can understand exactly how the component under consideration is being added to Linux, as well as which parameters should be paid first. Immediately clarify that for installation and further interaction with MySQL you will need an active Internet connection, since the archives will be obtained from official repositories.

Step 1: Preliminary actions

Of course, you can immediately proceed to the next step and perform installation, however, it will be necessary to determine the host name and make sure that the CentOS now has all the latest updates. Adjust the following instructions to prepare OS.

  1. These and all subsequent actions will be made through the Terminal, respectively, it will be necessary to run convenient for you. You can do this through the application menu or shrinking the Ctrl + Alt + T. key combination.
  2. Transition to the terminal for preparatory actions when installing MySQL in Sentos 7

  3. Here enter the hostname command and click on ENTER.
  4. Enter the command to define the name of the host in MySQL in Sentos 7

  5. Additionally, specify HostName -F and compare two results. The first is complete, and the second - abbreviated. If it suits you, go further. Otherwise, you will have to change the host name by using instructions from the official documentation.
  6. The command for displaying the abbreviated host name for MySQL in Sentos 7

  7. Before installing any application, it is recommended to check the availability of updates so that all subsequent processes go correctly. To do this, enter Sudo Yum Update and click on ENTER.
  8. A command to receive updates before installing MySQL in Sentos 7

  9. This option is executed on behalf of the superuser, which means you need to enter a password to confirm the authentication of the account. Consider that when writing characters, they will not be displayed in the console.
  10. Password entry to receive updates before installing MySQL in Sentos 7

  11. You will be notified of the need to install updated packages, or an alert that updates are not found on the screen.
  12. Successful receipt of updates before installing MySQL in Sentos 7

After installing all updates, it is recommended to restart the system to change the changes. If the updates were found not, immediately go to the next stage.

Step 2: Downloading and installing packages

Unfortunately, you will not be able to download MySQL from the official repository and simultaneously install it with one command. This is due to a huge number of versions and certain nuances with the addition of archives, so first the choice of a suitable package must first.

Go to official warehouses MySQL

  1. Go to the above link to familiarize yourself with all the existing versions of the database management system under consideration. Select the package of interest in the RPM format and copy the link to it by calling the context menu by pressing the right mouse button.
  2. Downloading the chosen package RPM package with a version of MySQL in Sentos 7

  3. When you insert, you will see that the link was copied correctly, and if you go through the browser, you will download the RPM package, but now it is not necessary for us, so we will move to the console.
  4. View Copied Link to download Package with MySQL in Sentos 7

  5. Once in the Terminal, enter the WGET + copied previous link and click on ENTER.
  6. Downloading MySQL package in Sentos 7 through the terminal

  7. Next, use Sudo RPM -IVH MySQL57-Community-Release-EL7.RPM, replacing the mismatch in this line to the numbers specified in the existing link.
  8. Additional command for downloading MySQL installation package in Sentos 7

  9. This operation is also carried out on behalf of the superuser, and therefore you have to re-enter the password.
  10. Confirmation of the download package of the MYSQL installation in Sentos 7

  11. Wait until the repository update is completed and install the package.
  12. Waiting for the completion of the MYSQL installation package in Sentos 7

  13. Before starting the main installation process, update the repository list by specifying Sudo Yum Update.
  14. Command for recent repository updates when installing MySQL in Sentos 7

  15. Confirm the action performed by selecting the Y version.
  16. Confirmation of the update of repositories when installing MySQL in Sentos 7

  17. Do it again when you repeat.
  18. Second command to confirm the installation of updates when installing MySQL in Sentos 7

  19. Only the process of installing the system itself remained. This is done using the Sudo Yum Install MySQL-Server command.
  20. Command for installing MySQL in Sentos 7 through the terminal

  21. Confirm absolutely all requests for installation or packet unpacking.
  22. The download procedure may take a few minutes, which depends on the speed of the Internet. During this, do not close the terminal session so as not to reset all the settings.
  23. Waiting for the installation of the MYSQL DBMS in Sentos 7 through the terminal

  24. After successful installation, activate the server through the Sudo SystemCTL Start Mysqld.
  25. Running service to control MYSQL DBMS in Sentos 7 through the terminal

  26. If there are no errors with turning on, a new line for input will appear on the screen.
  27. Successful launch service of the MYSQL DBMS in Sentos 7 through the terminal

As you can see, installing MySQL in CentOS 7 took just a few minutes, and the user it took not so many commands, most of which can be simply copied and insert into the console. However, for correct interaction with the DBMS, it will be necessary to produce an initial configuration, which will be discussed below.

Step 3: Initial Setup

Now we will not affect absolutely all aspects of setting up the database management system, since this does not apply to the subject of the article. We just want to tell about the basic actions that need to be done to check the performance of the utility and assign standard rules for it. To do this, you will need to follow such a guide:

  1. Let's start with the installation of a handy editor, since all settings are changed in the configuration file, which opens through such a software. It is convenient to use Nano, so in the console, sudo yum Install Nano.
  2. Installing a text editor to edit MySQL settings in Sentos 7

  3. If the utility has not yet been established, you will have to confirm the addition of new archives. Otherwise, the string "perform nothing" will simply appear, therefore, you can move to the next step.
  4. Successful installation of a text editor to edit MySQL settings in Sentos 7

  5. Insert the sudo nano /etc/my.cnf and activate this command.
  6. Run a configuration file to configure MySQL in Sentos 7

  7. Add the bind_adddress = string = and specify the IP address to which you want to connect and open all ports. You can additionally specify other important parameters. Read more about them in the official documentation, the reference to which is shown below.
  8. Editing configuration file when setting up MySQL in Sentos 7

  9. After the changes, do not forget to write them down by clicking on Ctrl + O, and then exit from Nano via Ctrl + X.
  10. Saving changes in a text editor when configuring MySQL in Sentos 7

  11. Initially, the configuration file also contains parameters affecting the security of the network. They can be a potential weak place during hacking, therefore it is recommended to eliminate them by performing mysql_secure_installation.
  12. MYSQL security team in Sentos 7

  13. To confirm this operation, enter the administrator password.

As mentioned earlier, we only demonstrated the basic principle of configuration. More detailed about this is written in the official documentation of MySQL Next.

Jump to reading MySQL documentation on the official website

Step 4: Root Root Password Reset

Sometimes users when installing MySQL set a superuser password, and then forget it or do not know which it was chosen initially, so we decided to finally decide on this article to reset the access key, which is carried out like this:

  1. Open the "Terminal" and enter the Sudo SystemCTL Stop MySQLD there to stop the execution of the service.
  2. Disable MYSQL service in Sentos 7 to reset the password

  3. Go to the secure mode of operation via SystemCTL Set-Environment MySqld_opts = "- Skip-Grant-Tables."
  4. Run MYSQL in Sentos 7 in secure mode for password reset

  5. Connect from the name of the superuser by entering MySQL -U root. The password will not be requested.
  6. Entering commands to reset the MYSQL password in Sentos 7 through the terminal

  7. It remains only in turns to execute the following commands to create a new access key.

    MySQL> Use MySQL;

    MySQL> Update User Set Password = Password ("Password") WHERE User = 'ROOT'; (where password is your new access key)

    MySQL> Flush Privileges;

    Sudo SystemCTL Unset-Environment Mysqld_opts

    Sudo SystemCTL Start MySqld

After that, try connecting to the server again using the new password. This time there should be no difficulty.

You have just been familiar with the step-by-step manual for installing and surface configuration MySQL in CentOS 7. As you can see, there is nothing difficult in this, but you should not consider the above recommendations with a full guide to connect the database to further interact with the web server or the application. All this will have to be done manually, pushing away from the specifics of the site, the program and studying the official documentation of all components used.

See also:

Installing phpMyadmin in CentOS 7

Installation PHP 7 in CentOS 7

Read more