In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to install Mysql8.0 in Centos7. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Install mysql8.0 download installation package
Official download address of mysql: https://dev.mysql.com/downloads/
Select: MySQL Community Server
If you have no choice of centos for centos, you can choose redhat. You need to check the kernel version, which is the el7,64 bit. The command is as follows:
) # 1 SMP Tue Jun 18 16:35:19 UTC 2019
Download the installation package (mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar); bundle contains all packages by package; unzip it with the tar-xvf command
[root@iZ2ze8diszrt8lvjh9yr86Z mysql] # tar-xvf mysql-8.0.18-1.el7.aarch74.rpm-bundle.tar mysql-community-embedded-compat-8.0.18-1.el7.aarch74.rpmmysql-community-libs-compat-8.0.18-1.el7.aarch74.rpmmysql-community-devel-8.0.18-1.el7.aarch74.rpmmysql-community-test-8.0.18-1.el7.aarch74.rpmmysql-community-libs-8.0.18-1.el7 .aarch74.rpmmysql-community-common-8.0.18-1.el7.aarch74.rpmmysql-community-server-8.0.18-1.el7.aarch74.rpmmysql-community-client-8.0.18-1.el7.aarch74.rpm
It can also be installed through yum install mysql-community-server, but the package is relatively large
You can also get it through wget, which is more convenient, but you need to log in to the official website and find the corresponding download url.
[root@iZ2ze8diszrt8lvjh9yr86Z mysql] # wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar--2019-10-25 14-34-51-https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.18-1.el7.x86_64.rpm-bundle.tarResolving dev.mysql.com (dev.mysql.com). 137.254.60.11Connecting to dev.mysql.com (dev.mysql.com) | 137.254.60.11 |: 443. Connected.HTTP request sent, awaiting response... 302 FoundLocation: https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar [following]-- 2019-10-25 14-14 FoundLocation 34-53 following-https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.18-1.el7.x86_64.rpm-bundle.tarResolving cdn.mysql.com (cdn.mysql.com). 23.56.181.34Connecting to cdn.mysql.com (cdn.mysql.com) | 23.56.181.34 |: 443. Connected.HTTP request sent, awaiting response...
Mariadb is installed by default in centos7, which needs to be uninstalled first.
[root@iZ2ze8diszrt8lvjh9yr86Z mysql] # rpm-qa | grep mariadbmariadb-libs-5.5.60-1.el7_5.x86_64 [root@iZ2ze8diszrt8lvjh9yr86Z mysql] # rpm-qa | grep mariadb-server [root@iZ2ze8diszrt8lvjh9yr86Z mysql] # yum remove mariadb-libs.x86_64
The installation order rpm package has dependencies, as follows:
Rpm-ivh... Common.rpm
Rpm-ivh... Libs.rpm
Rpm-ivh... Client.rpm
Rpm-ivh... Server.rpm
[root@iZ2ze8diszrt8lvjh9yr86Z mysql] # lltotal 1999492 RWMUR Sep-1 root root 684851200 Sep 23 15:36 mysql-8.0.18-1.el7.x86copyright 64.rpmMurbundle.tarMel RWL-1 7155 31415 40104640 Sep 23 15:19 mysql-community-client-8.0.18-1.el7.x86q64.rpmMUR copyright RUV-1 7155 31415611436 Sep 23 15:20 mysql-community-common-8.0.18-1. El7.x86_64.rpm-rw-r--r-- 1 7155 31415 6915400 Sep 23 15:20 mysql-community-devel-8.0.18-1.el7.x86 Sep 64.rpm mysql-community-embedded-compat-8.0.18-1 7155 31415 23683600 Sep 23 15:20 RPM-1.el7.x86 Sep 64.rpmMuhasha Sep 23 15:20 RPM-1 .el7.x86 _ 64.rpmMurr Sep-1 7155 31415 1363968 Sep 23 15:20 mysql-community-libs-compat-8.0.18-1.el7.x86y64.rpmMMMUR Mustang-1 7155 31415 450282440 Sep 23 15:21 mysql-community-server-8.0.18-1.el7.x86copyright 64.rpmMurray rwMurray-1 7155 31415 158001648 Sep 23 15:22 mysql-community-test-8.0.18-1 .el7.x86 _ 64.rpm [root @ iZ2ze8diszrt8lvjh9yr86Z mysql] # rpm-ivh mysql-community-common-8.0.18-1.el7.x86_64.rpm warning: mysql-community-common-8.0.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature Key ID 5072e1f5: NOKEYPreparing... # # [100%] Updating / installing... 1:mysql-community-common-8.0.18-1.e## [root@iZ2ze8diszrt8lvjh9yr86Z mysql] # rpm-ivh mysql-community-libs-8.0.18-1.el7.x86_64.rpm warning: mysql-community-libs-8.0.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing... # # [100%] Updating / installing... 1:mysql-community-libs-8.0.18-1.el7## [root@iZ2ze8diszrt8lvjh9yr86Z mysql] # rpm-ivh mysql-community-client-8.0.18-1.el7.x86_64.rpm warning: mysql-community-client-8.0.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing... # # [100%] Updating / installing... 1:mysql-community-client-8.0.18-1.e## [root@iZ2ze8diszrt8lvjh9yr86Z mysql] # rpm-ivh mysql-community-server-8.0.18-1.el7.x86_64.rpm warning: mysql-community-server-8.0.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing... # # [100%] Updating / installing... 1:mysql-community-server-8.0.18-1.e## [100%] [root@iZ2ze8diszrt8lvjh9yr86Z mysql] #
Mysql8 is installed to / var/lib/mysql by default
[root@iZ2ze8diszrt8lvjh9yr86Z mysql] # ll / var/lib/mysqltotal 155716 binlog.index-rw- RW mysql mysql r-1 mysql mysql 56 Oct 25 14:52 auto.cnf-rw-r- 1 mysql mysql 178 Oct 25 14:53 binlog.000001-rw-r- 1 mysql mysql 16 Oct 25 14:52 binlog.index-rw- 1 mysql mysql 1680 Oct 25 14:52 ca-key.pem-rw-r--r-- 1 mysql mysql 1112 Oct 25 14:52 ca.pem-rw-r--r-- 1 mysql mysql 1112 Oct 25 14:52 client-cert.pem-rw- 1 mysql mysql 1680 Oct 25 14:52 client-key.pem-rw-r- 1 mysql mysql 3449 Oct 25 14:53 ib_buffer_pool-rw-r- 1 mysql mysql 12582912 Oct 25 14:53 ibdata1-rw-r- 1 mysql mysql 50331648 Oct 25 14:53 ib_logfile0-rw-r- 1 mysql mysql 50331648 Oct 25 14:52 ib_logfile1drwxr-x--- 2 mysql mysql 4096 Oct 25 14:53 # innodb_tempdrwxr-x--- 2 mysql mysql 4096 Oct 25 14:52 mysql-rw-r- 1 mysql mysql 25165824 Oct 25 14:52 mysql.ibddrwxr-x--- 2 mysql mysql 4096 Oct 25 14:52 performance_schema-rw- 1 mysql mysql 1680 Oct 25 14:52 private_key.pem-rw-r--r-- 1 mysql mysql 452 Oct 25 14:52 public_key.pem-rw-r--r-- 1 mysql mysql 1112 Oct 25 14:52 server-cert.pem-rw- 1 mysql mysql 1680 Oct 25 14:52 server-key.pemdrwxr-x--- 2 mysql mysql 4096 Oct 25 14:52 sys-rw-r- 1 mysql mysql 10485760 Oct 25 14 : 53 undo_001-rw-r- 1 mysql mysql 10485760 Oct 25 14:53 undo_002
The default profile is in / etc/my.cnf
Mysql start and stop
You can start and stop mysql through the service mysqld service.
[root@iZ2ze8diszrt8lvjh9yr86Z mysql] # service mysqld startRedirecting to / bin/systemctl start mysqld.service [root@iZ2ze8diszrt8lvjh9yr86Z mysql] # [root@iZ2ze8diszrt8lvjh9yr86Z mysql] # service mysqld statusRedirecting to / bin/systemctl status mysqld.service ● mysqld.service-MySQL Server Loaded: loaded (/ usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Fri 2019-10-25 14:52:50 CST 2s ago Docs: man:mysqld (8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 12015 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited Status=0/SUCCESS) Main PID: 12094 (mysqld) Status: "Server is operational" CGroup: / system.slice/mysqld.service └─ 12094 / usr/sbin/mysqldOct 25 14:52:42 iZ2ze8diszrt8lvjh9yr86Z systemd [1]: Starting MySQL Server...Oct 25 14:52:50 iZ2ze8diszrt8lvjh9yr86Z systemd [1]: Started MySQL Server. [root@iZ2ze8diszrt8lvjh9yr86Z mysql] # service mysqld stopRedirecting to / bin/systemctl stop mysqld.service change password
1. After you have just started successfully, use the command to view the default password and log in
Default password view: cat / var/log/mysqld.log | grep password login: mysql-u root-p and enter the password
two。
[root@iZ2ze8diszrt8lvjh9yr86Z mysql] # cat / var/log/mysqld.log | grep password2019-10-25T06:52:47.021899Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: lV.66%i > mmai 7F [root@iZ2ze8diszrt8lvjh9yr86Z mysql] # mysql-u root-pEnter password: Welcome to the MySQL monitor. Commands end with; or\ g.Your MySQL connection id is 8Server version: 8.0.18Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or'\ h' for help. Type'c'to clear the current input statement.# modify password policy mysql > set global validate_password.policy=0;Query OK, 0 rows affected (0.00 sec) # modify password length check mysql > set global validate_password.length=1;Query OK, 0 rows affected (0.00 sec) # modify root password mysql > ALTER USER "root" @ "localhost" IDENTIFIED BY "123456"; Query OK, 0 rows affected (0.01 sec) initiate remote access
First turn off the firewall
/ / temporarily shuts down systemctl stop firewalld// and forbids starting systemctl disable firewalld.
Mysql8.0 has modified the default authentication rule; in the previous version, the encryption rule is mysql_native_password, but after mysql8, the encryption rule is caching_sha2_password. There are two ways to solve this problem, one is to upgrade the client driver, and the other is to restore the mysql login password encryption rule to mysql_native_password.
However, most of the online tutorials change root to remote connection and modify the authentication mode. This is not recommended. If there is a slight problem with the operation, the mysql will not be able to link, so it is troublesome to solve.
Here, create a new user admin, pay all permissions, and perform remote maintenance; the operation is as follows
Mysql > use mysqlReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with-ADatabase changed# create admin user mysql > create user 'admin'@'%' identified by' Admin123';Query OK, 0 rows affected (0.00 sec) # pay all permissions mysql > grant all on *. * to 'admin'@'%'; Query OK, 0 rows affected (.01 sec) mysql > flush privileges Query OK, 0 rows affected (0. 00 sec) # modify admin authentication mode and password mysql > ALTER USER 'admin'@'%' IDENTIFIED WITH mysql_native_password BY' Admin123';Query OK, 0 rows affected (0. 00 sec) # Refresh permission mysql > flush privileges;Query OK, 0 rows affected (0. 01 sec) # exit using new user authentication login [root@iZ2ze8diszrt8lvjh9yr86Z] # mysql-uadmin-pEnter password: Welcome to the MySQL monitor. Commands end with; or\ g.Your MySQL connection id is 22Server version: 8.0.18 MySQL Community Server-GPLCopyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or'\ h' for help. Type'\ c' to clear the current input statement.mysql > use mysqlReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with-ADatabase changed# View user configuration mysql > select host,user,plugin from user +-+ | host | user | plugin | +- -+ |% | admin | mysql_native_password | | localhost | mysql.infoschema | caching_sha2_password | | localhost | mysql.session | caching_sha2_password | | localhost | mysql.sys | caching_sha2_password | | localhost | root | caching_sha2_password | +- -+
After that, the remote client Navicat is used to verify and the link is successful.
At this point, all mysql installations are complete ~! ~
Mysql uninstall
There is no operation here, only as a record
First, stop mysql service mysqld stop
There are two steps in total:
1. Uninstall mysql components
two。 Delete related folders
# the first step is to uninstall mysql components # View MySQL components [root@localhost ~] # rpm-qa | grep-I mysqlmysql-community-libs-8.0.12-1.el7.x86_64mysql-community-common-8.0.12-1.el7.x86_64mysql-community-client-8.0.12-1.el7.x86_64mysql-community-server-8.0.12-1.el7.x86_64# delete [root@localhost ~] # rpm-ev mysql- Community-server-8.0.12-1.el7.x86_64Preparing packages...mysql-community-server-8.0.12-1.el7.x86_64warning: / etc/my.cnf saved as / etc/my.cnf.rpmsave# deletion [root@localhost ~] # rpm-ev mysql-community-client-8.0.12-1.el7.x86_64Preparing packages...mysql-community-client-8.0.12-1.el7.x86_64# deletion failed [root@localhost ~] # rpm-ev mysql-community-common-8.0.12-1.el7.x86_64error: Failed dependencies: mysql-community-common (x86-64) > = 8.0.0 is needed by (installed) mysql-community-libs-8.0.12-1.el7.x86_64# continue to view [root@localhost ~] # rpm-qa | grep-I mysqlmysql-community-libs-8.0.12-1.el7.x86 8.0.12-1.el7.x86_64# delete [root@localhost ~] # rpm-e-- noscripts mysql-community-libs-8.0.12-1.el7.x86_64# Delete [root@localhost ~] # rpm-e-- noscripts mysql-community-common-8.0.12-1.el7.x86_64# View [root@localhost ~] # rpm-qa | grep-I mysql# step 2: delete related directories # View [root@localhost ~] # find /-name mysql/etc/mysql/etc/selinux/targeted/active/modules/100/mysql/var/lib/mysql/var/lib/mysql/mysql# delete [root@localhost ~] # rm-rf / etc/mysql [root@localhost ~] # rm-rf / etc/selinux/targeted/active/modules/100/mysql [root@localhost ~] # rm-rf / var/lib/mysql [root@localhost ~] # find /-name mysql# check again Nothing indicates that the uninstall succeeded [root@localhost ~] # rpm-qa | problem 1 of grep-I mysqlmysql installation
Warning when CentOS installs rpm installs MySQL:
[root@iZ2ze8diszrt8lvjh9yr86Z mysql] # rpm-ivh mysql-community-server-8.0.18-1.el7.x86_64.rpm warning: mysql-community-server-8.0.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Reason: this is due to the solution caused by yum installing the old version of GPG keys: add-- force-- nodeps such as: rpm-ivh mysql-community-server-8.0.18-1.el7.x86_64.rpm-- force-- nodeps.
It's just a warning. It's okay not to deal with it.
Question two
Prompt libaio.so.1 () (64bit) is needed by mysql-community-server-8.0.18-1.el7.x86_64
[root@iZ2ze8diszrt8lvjh9yr86Z mysql] # rpm-ivh mysql-community-server-8.0.18-1.el7.x86_64.rpm warning: mysql-community-server-8.0.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature Key ID 5072e1f5: NOKEYerror: Failed dependencies: libaio.so.1 () (64bit) is needed by mysql-community-server-8.0.18-1.el7.x86_64 libaio.so.1 (LIBAIO_0.1) (64bit) is needed by mysql-community-server-8.0.18-1.el7.x86_64 libaio.so.1 (LIBAIO_0.4) (64bit) is needed by mysql-community-server-8.0.18-1. El7.x86_64 [root@iZ2ze8diszrt8lvjh9yr86Z mysql] # yum install libaio
Yum install libaio is now ok, so you can continue to install mysql.
Mysql commonly used configuration query # query mysql maximum number of connections set show global variables like 'max_conn%';# View current user links show global status like' Max_used_connections';# check whether slow log is enabled and log location show variables like 'slow_query%';# view slow log timeout recording time show variables like' long_query_time' # View link creation and current number of links show status like 'Threads%';# view database current link show processlist;# view database configuration show variables like'% quer%';mysql configuration file my.cnf
Please adjust the parameters according to the actual situation, do not copy brainless
# unique number of Mysql service each mysql service Id requires unique server-id = "Service port number default 3306port = 3306#mysql installation root directory basedir = / var/share/mysql-8.0#mysql data file location datadir = / var/lib/mysql#pidpid-file = / var/lib/mysql/mysql.pid# setting socke file directory socket = / tmp/mysql.sock# setting temporary directory tmpdir = / tmp# User user = allowed access to the IP segment of mysql# bind-address = 0.0.0.login skipping password # skip-grant-tables# is mainly used for MyISAM storage engine If multiple servers connect to a database, it is recommended to comment below that skip-external-locking# can only check the login of the client with the IP address. Do not use hostname skip_name_resolve = transaction isolation level, default is repeatable. MySQL defaults to repeat read level (this level may have a lot of interlocking parameters, affecting performance) transaction_isolation = READ-COMMITTED# database default character set, mainstream character set supports some special emoji (special emoji occupies 4 bytes) character-set-server = utf8mb4# database character set corresponds to some sorting and other rules Allow a null value of null _ defaults_for_timestamp = the size of the true#SQL packet sent. If a BLOB object is suggested to be modified to 1Gmax_allowed_packet = 128M#MySQL connection idle for more than a certain period of time (in seconds), it will be forcibly closed # MySQL default wait_timeout value is 8 hours, and the interactive_timeout parameter needs to be configured at the same time to take effect. The maximum value of interactive_timeout = 1800wait_timeout = 180 internal memory temporary table is set to 128m. # for example, for group by with a large amount of data, temporary tables may be used in order by. If this value is exceeded, it will be written to disk. System IO pressure increases tmp_table_size = 134217728max_heap_table_size = 134217728 # disable mysql's cache query result set function # decide whether to turn it on later according to the business situation # close the following two items query_cache_size = 0query_cache_type = "database error log file log_error = error.log# slow query sql log setting slow_query_log = 1slow_query_log_file = slow in most cases .log # check the sqllog_queries_not_using_indexes that is not used for the index = when enabled for log_queries_not_using_indexes The frequency of recording slow sql, the number of records per minute log_throttle_queries_not_using_indexes = seconds as slave, and how slow sql is copied from the library will also be recorded log_slow_slave_statements = seconds of slow query execution This value must be reached and the number of rows that can be retrieved by long_query_time = records must reach this value before it can be recorded as the expiration time of the slow query min_examined_row_limit = 100#mysql binlog log file, and the expire_logs_days = 5 slow query will be automatically deleted after expiration.
Slow_query_log slow query enabled status slow_query_log_file slow query log storage location (this directory requires the writable permission of the running account of MySQL, generally set to the data storage directory of MySQL) how many seconds does the long_query_time query take to record?
Mysql > show variables like 'slow_query%' +-- +-- + | Variable_name | Value | + -- + | slow_query_log | OFF | | slow_query_log_file | / mysql/data/localhost-slow.log | +-- -+ mysql > show variables like 'long_query_time' +-+ | Variable_name | Value | +-+-+ | long_query_time | 10.000000 | +-+-+ method 1: modify global variables # set the slow_query_log global variable to the "ON" status mysql > set global slow_query_log='ON' # set the location of slow log storage mysql > set global slow_query_log_file='/usr/local/mysql/data/slow.log';# query for more than 3 seconds record mysql > set global long_query_time=3; method 2: configuration file settings
Modify the configuration file my.cnf and add under [mysqld]
[mysqld] slow_query_log = ONslow_query_log_file = / usr/local/mysql/data/slow.loglong_query_time = 3
3. Restart the MySQL service
Service mysqld restart
4. View the parameters after setting
Mysql > show variables like 'slow_query%' +-+ | Variable_name | Value | +-+- -+ | slow_query_log | ON | | slow_query_log_file | / usr/local/mysql/data/slow.log | +-- + mysql > show variables like 'long_query_time' +-+-+ | Variable_name | Value | +-+-+ | long_query_time | 1.000000 | +-+-+ this article on "how to install Mysql8.0 in Centos7" ends here. Hope that the above content can be helpful to you, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.
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.