In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Today, I will talk to you about how to install mysql8 in the centos7 system, many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
1. RPM version installation
Check to see if there are other versions of the database, and if so, delete it clean
Non-root users must have sudo permission
1. Download mysql related installation package
Https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql80-community-el7/mysql-community-server-8.0.18-1.el7.x86_64.rpm
Https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql80-community-el7/mysql-community-libs-8.0.18-1.el7.x86_64.rpm
Https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql80-community-el7/mysql-community-common-8.0.18-1.el7.x86_64.rpm
Https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql80-community-el7/mysql-community-client-8.0.18-1.el7.x86_64.rpm
two。 Other dependencies (you can skip this step and install whatever dependencies are missing when installing mysql later)
Go to the site to find gcc, gcc-c++, openssl, perl and their dependent packages
Https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/Packages/
3. Install mysql (if no error is reported, the installation is successful)
4. Custom configuration mysql (if you do not want to change the default related directory of mysql, skip to step 6)
Modify the default profile contents of Mysql
Sudo vi / etc/my.cnf
Delete everything and add the following:
[mysqld] user=mysqlport=3306datadir=/app/mysql/datasocket=/app/mysql/mysql.socklog-error=/app/mysql/log/mysqld.logpid-file=/app/mysql/ mysqld.pid[client] socket=/app/mysql/mysql.sock
5. Create related directories in the configuration file and modify permissions
Sudo mkdir / app/mysql/data / app/mysql/log-psudo chown mysql:mysql / app/mysql-R
6. Initialize mysql
7. Start mysql
If there is a startup error:
a. Please check whether the user and group of the mysql-related directory are mysql
b. Check whether selinux is off: execute sudo getenforce to get a result other than Permissive, execute the command: sudo setenforce 0
c. Check if the port is occupied
d. If it still fails to start: check the mysql error log and sudo systemctl status mysqld or journalctl-xe
8. Log in to mysql
Check the initial password of Mysql (root@localhost: followed by the initial password)
Sudo cat / app/mysql/log | grep root@localhost (use this command after doing step 4) sudo cat / var/log/mysqld.log | grep root@localhost (do not do step 4 use this command)
Log in to mysql and copy the password above
Mysql-p
9. Change the mysql password (you must change the password for the first login, otherwise you cannot use the mysql command)
Alter user 'root'@'localhost' identified by' your password
II. Installation of the source version
Non-root users must have sudo permission
1. Download related source packages
Https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.gz
Https://mirrors.tuna.tsinghua.edu.cn/gnu/gmp/gmp-6.2.0.tar.xz
Https://mirrors.tuna.tsinghua.edu.cn/gnu/m4/m4-latest.tar.gz
Https://mirrors.tuna.tsinghua.edu.cn/gnu/mpfr/mpfr-4.0.2.tar.gz
Https://mirrors.tuna.tsinghua.edu.cn/gnu/mpc/mpc-1.1.0.tar.gz
Https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-8.0/mysql-8.0.19.tar.gz
Http://dl.bintray.com/boostorg/release/1.70.0/source/boost_1_70_0.tar.gz
Https://down.24kplus.com/linux/cmake/cmake-3.16.2.tar.gz
two。 Install lower versions of gcc and gcc-c++ (must be done, otherwise configure will report an error when upgrading gcc and installing m4/gmp/mpfr/ MPC: configure: error: no acceptable C compiler found in $PATH)
Go to the URL to find gcc, gcc-c++ and their dependent packages (those who can connect to the external network can directly use the command: sudo yum-y install gcc gcc-c++)
Https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/Packages/
3. Install the source version of cmake
Openssl and openssl-devel dependencies must be installed, and the download URL is the same as above, otherwise bootstrap will report an error: openssl cannot be found (if you can connect to the external network, you can directly use the command: sudo yum-y install openssl openssl-devel)
Tar cmake-3.16.1.tgzcd cmake-3.16.1sudo. / bootstrap sudo make sudo make checksudo make install
4. Upgrade gcc, gcc-c++
a. Install M4
Tar-xzvf m4-latest.tar.gzcd M4-1.4.17/sudo. / configure-- prefix=/usr/local (--prefix specified installation path) sudo make (compile) sudo make check (check for compilation errors, note whether there is Error, do not have to do it) sudo make install (install) M4-- version (check M4 version)
After the correct installation, you can see the following results
b. Install gmp
Sudo ln-s / usr/local/bin/m4 / usr/bin (make a soft connection of M4 to this path, otherwise configure will report an error: checking for suitable M4. Configure: error: No usable M4 in $PATH or / usr/5bin (see config.log for reasons).) tar-xvf gmp-6.2.0.tar.xzcd gmp-6.2.0sudo. / configure-- prefix=/usr/local/gmp-6.2 (non-administrator must have sudo, or error: Permission denied) sudo makesudo make checksudo make install
c. Install mpfr
Tar-xzvf mpfr-4.0.2.tar.gz cd mpfr-4.0.2 sudo. / configure-- prefix=/usr/local/mpfr-4.0-- with-gmp=/usr/local/gmp-6.2 (--with-gmp is the installation directory of gmp) sudo makesudo make checksudo make install
d. Install mpc
Tar-xzvf mpc-1.1.0.tar.gzcd mpc-1.1sudo. / configure-prefix=/usr/local/mpc-1.1-with-gmp=/usr/local/gmp-6.2-with-mpfr=/usr/local/mpfr-4.0sudo makesduo make checksudo make install
e. Add the library file (/ usr/local/mpfr-4.0/lib/ must be added to the library file, the other two can not be done, otherwise you will get an error when installing and upgrading gcc compilation: error while loading shared libraries: libmpfr.so.6: cannot open shared object file: No such file or directory)
Sudo vi / etc/ld.so.conf / usr/local/mpfr-4.0/lib/ / usr/local/gmp-6.2/lib / usr/local/mpc-1.1/libsudo ldconfig (to make the above operation effective)
Or make a soft connection
Sudo ln-s / usr/local/mpfr-4.0/lib/libmpfr.so.6 / usr/bin
Or copy.
Sudo cp / usr/local/mpfr-4.0/lib/libmpfr.so.6 / usr/bin/
f. Install other dependencies (it must be installed when the system does not have a dependency package installed, otherwise there will be an error when upgrading gcc compilation: mpc.h: there is no such file or directory)
Download gmp-devel and libmpc-devel and their dependent packages (if you can connect to the external network, you can directly use the command: sudo yum-y install gmp-devel libmpc-devel)
Https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/Packages/gmp-6.0.0-15.el7.x86_64.rpm
Https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/Packages/gmp-devel-6.0.0-15.el7.x86_64.rpm
Https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/Packages/libmpc-1.0.1-3.el7.x86_64.rpm
Https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/Packages/libmpc-devel-1.0.1-3.el7.x86_64.rpm
Https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/Packages/mpfr-3.1.1-4.el7.x86_64.rpm
Https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/Packages/mpfr-devel-3.1.1-4.el7.x86_64.rpm
If you still have dependent packages to download, please go to https://mirrors.tuna.tsinghua.edu.cn to download them yourself
g. Upgrade gcc
Tar-xzvf gcc-9.2.0.tar.gzcd gcc-9.2.0 sudo. / configure-- prefix=/usr/local/gcc-9.2\-enable-bootstrap\-- enable-checking=release\-- enable-languages=c C++\-- enable-threads=posix\-- disable-checking\-- disable-multilib\-- enable--long-long\-- with-gmp=/usr/local/gmp-6.2\-- with-mpfr=/usr/local/mpfr-4.0\-- with-mpc=/usr/local/mpc-1.1sudo make (compile time is long, 1 hour) sudo make checksudo make install
Be sure to uninstall the lower versions of gcc and gcc-c++
Sudo rpm-e gcc-c++sudo rpm-e gccsudo vi / etc/profile export PATH=$PATH:/usr/local/gcc/bin source / etc/profile
View the gcc version number
Gcc-version
5. Install the source version of mysql
Install ncurses-devel dependency, otherwise cmake error: Curses library not found.Please install appropriate package (those who can connect to the external network can directly use the command: sudo yum-y install ncurses-devel, the download address that cannot connect to the external network is the same as in step 2)
Tar-xzvf mysql-8.0.19.tar.gzcd mysql-8.0.19cmake. -DCMAKE_INSTALL_PREFIX=/app/mysql\-DDEFAULT_CHARSET=utf8\-DDEFAULT_COLLATION=utf8_general_ci\-DENABLED_LOCAL_INFILE=ON\-DWITH_SSL=system\-DMYSQL_DATADIR=/app/mysql/data\-DSYSCONFDIR=/app/mysql/config\-DMYSQL_TCP_PORT=3306\-DMYSQL_UNIX_ADDR=/app/mysql/mysql.sock\-DWITH_BOOST=/home/mcbadm/mysql8/\-DFORCE_INSOURCE_BUILD=1-DDEFAULT_CHARSET: set character set-DDEFAULT_ COLLATION: set collation-DENABLED_LOCAL_INFILE=ON: enable local data import support-DWITH_SSL=system: enable ssl library support-DMYSQL_DATADIR: data file directory Arbitrary-DSYSCONFDIR: configuration file directory, arbitrary-DMYSQL_TCP_PORT:mysql listening TCP port-DMYSQL_UNIX_ADDR:mysql.sock path, arbitrary-DWITH_BOOST:boost source package directory-DFORCE_INSOURCE_BUILD: force the establishment of a non-existing resource directory cmake if an error is reported Please find out the reason and delete CMakeCache.txt again cmakesudo rm-rf / usr/lib64/libstdc++.so.6* (delete all the earlier version of C++ library files) sudo ln-s / usr/local/gcc-9.2/lib64 / usr/lib64 (add the newly installed C++ library files to the system library files) sudo make (it will take about 1 hour) sudo make install
6. Write configuration files, establish directories, and authorize
Sudo mkdir / app/mysql/configsudo cd / app/mysqlsudo vi config/my.cnf
Add the following:
[mysqld] user=mysqlport=3306datadir=/app/mysql/datasocket=/app/mysql/ mysql.sock [mysqld _ safe] log-error=/app/mysql/logs/mysql-err.logpid-file=/app/mysql/ mysql.pid [client] socket=/app/mysql/mysql.socksudo useradd mysql- s / sbin/nologinsudo mkdir-p / app/mysql/logssudo touch / app/mysql/logs/mysql-err.logsudo chown-R mysql.mysql / app/mysql
7. Initialize and log in to change the password
Initialization
Sudo / app/mysql/bin/mysqld-- initialize-insecure-- user=mysql-- datadir=/app/mysql/data-- basedir=/app/mysql (if you don't have an initial password, if you want an initial password, use-- initialize)
Start
Sudo / app/mysql/support-files/mysql.server start
Log in (if you don't have the initial password, you can enter directly)
Sudo / app/mysql/bin/mysql-p
Modify the password
Alter user 'root'@'localhost' identified by' password
After reading the above, do you have any further understanding of how to install mysql8 in a centos7 system? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
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.