In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article is mainly about CentOS system installation MySQL commonly used several aspects of the content, if you are interested to take a look at this article, I believe that after reading the CentOS system installation MySQL commonly used several sides to you more or less reference value.
Several common ways to install software on Linux:
Source code compilation
Compressed package decompression (usually tar.gz)
Compiled installation package (RPM, DPKG, etc.)
Online installation (YUM, APT, etc.)
The convenience of the above methods increases in turn, but the versatility decreases in turn, such as downloading the compressed package directly for decompression, which generally requires some additional configuration work, but as long as you master the method, each platform is basically applicable. YUM is simple, but the platform is limited, the network is limited, and some specific YUM sources need to be added if necessary.
Several installation methods are best mastered. In principle, if you can use a simple one, you can use a simple one: YUM > RPM > tar.gz > source code.
This article is to introduce the installation of MySQL on CentOS. The main steps are to refer to the official MySQL document: dev.mysql.com/doc/refman/.
In order to test different installation methods, I repeated several times, installed and deleted, deleted and installed, and each step was tested successfully, and each command was executed in person, so you can rest assured to use it.
Let's cut down the gossip and return to the book.
1. YUM0, delete the installed MySQL, check MariaDBshell > rpm-qa | grep mariadb mariadb-server-5.5.60-1.el7_5.x86_64 mariadb-5.5.60-1.el7_5.x86_64 mariadb-libs-5.5.60-1.el7_5.x86_64 delete mariadb
If it does not exist (the above check result returned empty), skip the step
Shell > rpm-e-- nodeps mariadb-server shell > rpm-e-- nodeps mariadb shell > rpm-e-- nodeps mariadb-libs
In fact, there is no need to delete mariadb when installing yum. Installing MySQL will overwrite the existing mariadb.
Check MySQLshell > rpm-qa | grep mysql delete MySQL
If it does not exist (the above check result returned empty), skip the step
Shell > rpm-e-- nodeps xxx1, add MySQL Yum Repository
Starting with CentOS 7, MariaDB has become the default database installation package in the Yum source. This means that using yum to install MySQL on CentOS 7 and above will install MariaDB (a branch of MySQL) by default. If you want to install the official MySQL version, you need to use the Yum source provided by MySQL.
Download MySQL Feed
Official website address: dev.mysql.com/downloads/r …
View the system version:
Shell > cat / etc/redhat-release CentOS Linux release 7.6.1810 (Core)
Select the corresponding version to download. For example, the download address for CentOS 7 to view the latest Yum source on the official website is: dev.mysql.com/get/mysql80 …
Shell > wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm install MySQL source shell > sudo rpm-Uvh platform-and-version-specific-package-name.rpm
For example, the latest MySQL source installation of CentOS7:
Shell > sudo rpm-Uvh mysql80-community-release-el7-3.noarch.rpm check whether the installation is successful
After successful execution, two repo files, mysql-community.repo and mysql-community-source.repo, are generated in the / etc/yum.repos.d/ directory.
And you can see mysql related resources through yum repolist.
Shell > yum repolist enabled | grep "mysql.*-community.*"! mysql-connectors-community/x86_64 MySQL Connectors Community 108! mysql-tools-community/x86_64 MySQL Tools Community 90! mysql80-community/x86_64 MySQL 8.0 Community Server 1132, select MySQL version
To install MySQL using MySQL Yum Repository, the latest stable version is selected by default. For example, if you install through the above MySQL source, MySQL 8.0 is selected by default. If you want to install this version, you can skip this step directly. If not, for example, if I want to install the MySQL5.7 version here, you need to "switch versions":
View all MySQL versions in the current MySQL Yum Repository (each version is in a different sub-repository) shell > yum repolist all | grep mysql switch version shell > sudo yum-config-manager-- disable mysql80-community shell > sudo yum-config-manager-- enable mysql57-community
In addition to using yum-config-manager, you can edit the / etc/yum.repos.d/mysql-community.repo file directly
Enabled=0 disabled
[mysql80-community] name=MySQL 8.0 Community Server baseurl= http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch/ enabled=0 gpgcheck=1 gpgkey= file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Enabled=1 enabled
# Enable to use MySQL 5.7 [mysql57-community] name=MySQL 5.7 Community Server baseurl= http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/ enabled=1 gpgcheck=1 gpgkey= file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql checks the currently enabled MySQL repository shell > yum repolist enabled | grep mysql
If multiple repositories are enabled at the same time, the latest version will be selected during installation
3. Install MySQLshell > sudo yum install mysql-community-server
This command installs MySQL CVM (mysql-community-server) and its required dependencies and related components, including mysql-community-client, mysql-community-common, mysql-community-libs, etc.
If the bandwidth is not enough, this step will take a long time. Please wait patiently.
4. Start MySQL. Start shell > sudo systemctl start mysqld.service.
CentOS 6:
Shell > sudo service mysqld start View status shell > sudo systemctl status mysqld.service
CentOS 6:
Shell > sudo service mysqld status stop shell > sudo systemctl stop mysqld.service
CentOS 6:
Shell > sudo service mysqld stop restart shell > sudo systemctl restart mysqld.service
CentOS 6:
Shell > sudo service mysqld restart5, change password initial password
After MySQL starts for the first time, the Super Admin account root@localhost is created, and the initial password is stored in the log file:
Shell > sudo grep 'temporary password' / var/log/mysqld.log modify the default password shell > mysql-uroot-pmysql > ALTER USER' root'@'localhost' IDENTIFIED BY '123456password; ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
The above prompt appears because the password is too simple, and the solution is as follows:
Using complex passwords, MySQL's default password policy is to include numbers, letters, and special characters
If you only want to test and do not want to use such complex passwords, you can modify the default policy, that is, validate_password_policy (and related parameters such as validate_password_length), to support the setting of simple passwords. The specific method can be used by Baidu itself.
Modify the configuration file / etc/my.cnf, add validate_password=OFF, save and restart MySQL
Mysql > ALTER USER 'root'@'localhost' IDENTIFIED BY' 123456 encoding; Query OK, 0 rows affected (0.00 sec) 6, allow root remote access mysql > GRANT ALL PRIVILEGES ON *. * TO 'root'@'%' IDENTIFIED BY' 123456' WITH GRANT OPTION; mysql > FLUSH PRIVILEGES;7, set encoding to utf8 View Encoding mysql > SHOW VARIABLES LIKE 'character%';
Edit / etc/my.cnf, add the following code to the [mysqld] node:
[mysqld] collation-server=utf8_unicode_ci init-connect='SET NAMES utf8'8, set boot shell > systemctl enable mysqld shell > systemctl daemon- reload II, RPM
Except for the installation process, the other steps are the same as the yum installation and will not be repeated.
0. Delete the old version
Slightly
1. Download the MySQL installation package
Download address: dev.mysql.com/downloads/m …
Select the corresponding version:
Cdn.xitu.io/2019/6/18/16b66894c80e9b32?imageView2/0/w/1280/h/960/format/webp/ignore-error/1 ">
Shell > wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar2, Install MySQL decompress (unpack) shell > tar-xvf mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar tar-xvf mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar mysql-community-embedded-devel-5.7.26-1.el7.x86_64.rpm mysql-community-libs-5.7.26-1.el7.x86_64.rpm mysql-community-embedded-5.7.26-1.el7.x86 _ 64.rpm mysql-community-test-5.7.26-1.el7.x86_64.rpm mysql-community-embedded-compat-5.7.26-1.el7.x86_64.rpm mysql-community-common-5.7.26-1.el7.x86_64.rpm mysql-community-devel-5.7.26-1.el7.x86_64.rpm mysql-community-client-5.7.26-1.el7.x86_64.rpm mysql-community-server-5.7.26-1.el7.x86_64.rpm
We mainly install these four (you can also install other ones if necessary):
Mysql-community-libs-5.7.26-1.el7.x86_64.rpm mysql-community-common-5.7.26-1.el7.x86_64.rpm mysql-community-client-5.7.26-1.el7.x86_64.rpm mysql-community-server-5.7.26-1.el7.x86_64.rpm
If you do not want to download rpm-bundle, the official website also provides a separate link to download rpm.
Installation
Each rpm package has dependencies, so it needs to be installed in a certain order. If you are prompted which dependencies are missing during installation, install the corresponding packages first:
Shell > rpm-ivh mysql-community-common-5.7.26-1.el7.x86_64.rpm shell > rpm-ivh mysql-community-libs-5.7.26-1.el7.x86_64.rpm shell > rpm-ivh mysql-community-client-5.7.26-1.el7.x86_64.rpm shell > rpm-ivh mysql-community-server-5.7.26-1.el7.x86_64.rpm
There is also a simple way to automatically handle dependencies between packages and automatically download missing dependencies:
Shell > yum install mysql-community- {server,client,common,libs}-*
Note: the above yum install command needs to be executed in the directory of each rpm package after tar is decompressed, otherwise it will be installed in yum mode, the yum source of MySQL needs to be configured and the speed is very slow, and the current machine supports public network access.
3. Set up
Slightly
3. Tar.gz0, delete the old version
Slightly
1. Download
Download address: dev.mysql.com/downloads/m …
Select the corresponding version:
Shell > wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz2, installation & configuration: dependency
MySQL relies on the libaio library, if you don't install it first:
Shell > yum install libaio create mysql user
A system account that does not need to be logged in, which is used when starting the MySQL service
Shell > groupadd mysql shell > useradd-r-g mysql- s / bin/false mysql extract and create links shell > cd / usr/local shell > tar zxvf / path/to/mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz shell > ln-s mysql-5.7.26-linux-glibc2.12-x86_64/ mysql create mysql-files directory
This step is not required. You can set the value of secure_file_priv to point to this directory (the directory used to restrict data import and export operations)
Shell > cd mysql shell > mkdir mysql-files shell > chown mysql:mysql mysql-files shell > chmod 750mysql-files initialization shell > bin/mysqld-- initialize-- user=mysql
If the initialization Times is wrong as follows:
Error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
Because libnuma is not installed (or 32-bit is installed by default), we need 64-bit:
Shell > yum install numactl.x86_64
After reinitialization, you can initialize successfully. One line of the returned result contains the initial password, which is needed when you log in for the first time:
A temporary password is generated for root@localhost: 8M0ary878s*U enable SSL (optional) shell > bin/mysql_ssl_rsa_setup launch shell > bin/mysqld_safe-- user=mysql &
Viewing the process can see some default parameters, which can be modified in the configuration file
Shell > ps-ef | grep mysql root 14604 12719 0 00:03 pts/0 00:00:00 / bin/sh bin/mysqld_safe-- user=mysql mysql 14674 14604 0 00:03 pts/0 00:00:00 / usr/local/mysql/bin/mysqld-basedir=/usr/local/mysql-- datadir=/usr/local/mysql/data-- plugin-dir=/usr/local/mysql/lib/plugin-- user=mysql-- log-error=VM_2_24_centos.err-- pid-file=VM _ 2_24_centos.pid sets the environment variable
Avoid adding a path every time you execute the mysql command, add it to / etc/profile:
Export PATH=$PATH:/usr/local/mysql/bin is set to service shell > cp support-files/mysql.server / etc/init.d/mysqld shell > service mysqld start | stop | restart | status boot shell > chkconfig-- add mysqld shell > chkconfig-- list mysqld mysqld 0: off 1: off 2: on 3: on 4: on 5: on 6: off
The above details about several common methods of installing MySQL in CentOS system, are they helpful to you? If you want to know more about it, you can continue to follow our industry information section.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.