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--
Today, record how to install MySQL 8.0.18 on a CentOS 6.8 server, cut the crap and get straight to the topic.
Uninstall the MySQL that comes with CentOS 6.8.
First, uninstall the native MySQL on the CentOS 6.8 server and enter the following command on the command line to view the MySQL that comes with the CentOS 6.8 server.
[root@binghe151 src] # rpm-qa | grep-I mysql mysql-libs-5.1.73-7.el6.x86_64
As you can see, mysql-libs-5.1.73-7.el6.x86_64 is installed by default in the CentOS 6.8 server, and then mysql-libs-5.1.73-7.el6.x86_64 is uninstalled, as shown below.
[root@binghe151 src] # rpm-e mysql-libs-5.1.73-7.el6.x86_64-- nodeps [root@binghe151 src] #
Check the MySQL that comes with the CentOS 6.8 server again, as shown below.
[root@binghe151 src] # rpm-qa | grep-I mysql [root@binghe151 src] #
This indicates that the MySQL that comes with the CentOS 6.8 server was uninstalled successfully.
Second, install MySQL dependent environment
Before you can formally install MySQL, you first need to install the dependent underlying environment of MySQL, as shown below.
Yum-y install wget gcc-c++ ncurses ncurses-devel cmake make perl bison openssl openssl-devel gcc* libxml2 libxml2-devel curl-devel libjpeg* libpng* freetype* make gcc-c++ cmake bison-devel ncurses-devel bison perl perl-devel perl perl-devel net-tools* numactl*
3. Add mysql users
From the command line, execute the following command to add the mysql user.
Groupadd mysqluseradd-g mysql mysql
Download and install the RPM installation package for MySQL
First, from the command line of the CentOS 6.8 server, execute the following command to download the RPM installation package for MySQL 8.0.18.
Wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.18-1.el6.x86_64.rpm-bundle.tar
Next, take a look at the downloaded RPM installation package for MySQL 8.0.18, as follows
[root@binghe151 src] # lltotal 744876 RW Murray Ruby Murray. 1 root root 762746880 Nov 18 14:32 mysql-8.0.18-1.el6.x86_64.rpm-bundle.tar
Next, unpack the downloaded installation package, as shown below.
[root@binghe151 src] # tar xvf mysql-8.0.18-1.el6.x86_64.rpm-bundle.tar mysql-community-client-8.0.18-1.el6.x86_64.rpmmysql-community-test-8.0.18-1.el6.x86_64.rpmmysql-community-server-8.0.18-1.el6.x86_64.rpmmysql-community-libs-compat-8.0.18-1.el6.x86_64.rpmmysql-community-common-8. 0.18-1.el6.x86_64.rpmmysql-community-devel-8.0.18-1.el6.x86_64.rpmmysql-community-libs-8.0.18-1.el6.x86_64.rpm
Next, install it sequentially
Mysql-community-common-8.0.18-1.el6.x86_64.rpmmysql-community-libs-8.0.18-1.el6.x86_64.rpmmysql-community-client-8.0.18-1.el6.x86_64.rpmmysql-community-server-8.0.18-1.el6.x86_64.rpm
When installing, it needs to be installed in strict accordance with the above order.
First, install mysql-community-common-8.0.18-1.el6.x86_64.rpm, as shown below.
[root@binghe151 src] # rpm-ivh mysql-community-common-8.0.18-1.el6.x86_64.rpmwarning: mysql-community-common-8.0.18-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing... # [100%] 1:mysql-community-common #
Next, install mysql-community-libs-8.0.18-1.el6.x86_64.rpm, as shown below.
[root@binghe151 src] # rpm-ivh mysql-community-libs-8.0.18-1.el6.x86_64.rpmwarning: mysql-community-libs-8.0.18-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing... # [100%] 1:mysql-community-libs #
Next, install mysql-community-client-8.0.18-1.el6.x86_64.rpm, as shown below.
[root@binghe151 src] # rpm-ivh mysql-community-client-8.0.18-1.el6.x86_64.rpmwarning: mysql-community-client-8.0.18-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing... # [100%] 1:mysql-community-client #
Finally, install mysql-community-server-8.0.18-1.el6.x86_64.rpm, as shown below.
[root@binghe151 src] # rpm-ivh mysql-community-server-8.0.18-1.el6.x86_64.rpmwarning: mysql-community-server-8.0.18-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing... # [100%] 1:mysql-community-server #
If you report an error when installing mysql-community-server-8.0.18-1.el6.x86_64.rpm, it is shown below.
[root@binghe151 src] # rpm-ivh mysql-community-server-8.0.18-1.el6.x86_64.rpmwarning: mysql-community-server-8.0.18-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature Key ID 5072e1f5: NOKEYerror: Failed dependencies: libnuma.so.1 () (64bit) is needed by mysql-community-server-8.0.18-1.el6.x86_64 libnuma.so.1 (libnuma_1.1) (64bit) is needed by mysql-community-server-8.0.18-1.el6.x86_64 libnuma.so.1 (libnuma_1.2) (64bit) is needed by mysql-community-server-8.0.18-1.el6.x86_64
As you can see, the libnuma library is missing, so execute the following command to install libnuma.
Yum install numactl*-y
After executing the command, install mysql-community-server-8.0.18-1.el6.x86_64.rpm again.
Initialize MySQL data
First, let's talk about the official MySQL restrictions on running MySQL.
In MySQL 8.x, initialization data requires ensuring that the owner of the database directories and files is the mysql login account. If you are running the mysqld service as root, you need to verify that you execute the command with the-- user option shown below:
Shell > bin/mysqld-- initialize--user=mysqlshell > bin/mysqld-- initialize-insecure-- user=mysql
If you are logging in as an mysql account and executing the program, you can remove the-- user option from the command, as shown below.
Shell > bin/mysqld-- initializeshell > bin/mysqld-- initialize-insecure
From the above MySQL official restrictions on running MySQL, it can be concluded.
If you log in to the CentOS 6.8 server as root, you can execute the following command.
Mysqld-initialize--user=mysqlmysqld-initialize-insecure-user=mysql
If you log in to the CentOS 6.8 server as mysql, you can execute the following command.
Mysqld-initializemysqld-initialize-insecure
Because I am using a root account to log in to the CentOS 6.8 server here, when I initialize the database, I execute the following command.
Mkdir-p / usr/local/mysqlchown-R mysql.mysql / usr/local/mysqlmysqld-- initialize-- user=mysql-- basedir=/usr/local/mysql-- datadir=/usr/local/mysql/data
Note: here, when I execute the mysqld-- initialize command, I specify the directory where MySQL is installed. During the installation of MySQL, it is recommended that you specify the installation directory for MySQL. When the data directory exists in the / usr/local/mysql directory, initialization fails, and you must make sure that there is no data directory under / usr/local/mysql.
6. Start MySQL
Enter the following command from the CentOS 6.8 server command line to start the MySQL service.
[root@binghe151 src] # service mysqld startStarting mysqld: [OK]
When you start MySQL, a temporary login password is generated for MySQL's root account, which can be viewed in the / var/log/mysqld.log file. Open the / var/log/mysqld.log file using the vim editor, as shown below.
Vim / var/log/mysqld.log 2019-11-18T08:16:08.162464Z 0 [System] [MY-013169] [Server] / usr/sbin/mysqld (mysqld 8.0.18) initializing of server in progress as process 21112019-11-18T08:16:12.451542Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost:-8cagKkdK#5G2019-11-18T08:17:13.269505Z 0 [System] [MY-010116] [Server] / usr/sbin/mysqld (mysqld 8.0.18) starting as process 23782019-11-18T08:17:16.568836Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.2019-11-18T08:17:16.642494Z 0 [System] [MY-010931] [Server] / usr/sbin/mysqld: ready for connections. Version: '8.0.18' socket:'/ var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server-GPL.2019-11-18T08:17:16.652000Z 7 [Warning] [MY-013360] [Server] Plugin sha256_password reported:''sha256_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'2019-11-18T08:17:16.801986Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket:'/ var/run/mysqld/mysqlx.sock' bind-address:':: 'port: 33060
Find the following line of code.
2019-11-18T08:16:12.451542Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost:-8cagKkdK#5G
As you can see, the temporary login password generated when starting MySQL is-8cagKkdK#5G.
7. Log in to MySQL
Log in to MySQL with a temporary password, as shown below.
[root@binghe151 src] # mysql-uroot-p-8cagKkdK#5Gmysql: [Warning] Using a password on the command line interface can be insecure.Welcome to the MySQL monitor. Commands end with; or\ g.Your MySQL connection id is 9Server 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.mysql >
At this point, executing the SQL statement on the MySQL command line reports an error, requiring the password to be reset, as shown below.
Mysql > SHOW DATABASES;ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.mysql > use mysql;ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.mysql >
Next, change MySQL's root account password, as shown below.
Mysql > ALTER USER 'root'@'localhost' IDENTIFIED BY' root';Query OK, 0 rows affected (0.03 sec) mysql > FLUSH PRIVILEGES;Query OK, 0 rows affected (0.00 sec)
Next, enter the exit command at the MySQL command line to exit MySQL. Log in to MySQL again with the modified root password, as shown below.
Mysql > exitBye [root@binghe151 src] # mysql-uroot-prootmysql: [Warning] Using a password on the command line interface can be insecure.Welcome to the MySQL monitor. Commands end with; or\ g.Your MySQL connection id is 10Server 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 >
It indicates that the password of MySQL's root account has been changed successfully.
Next, execute the SQL statement again on the MySQL command line, as shown below.
Mysql > SHOW DATABASES;+-+ | Database | +-+ | information_schema | | mysql | | performance_schema | | sys | +-+ 4 rows in set (0.36 sec) mysql > USE mysql;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with-ADatabase changedmysql >
As you can see, after changing the root account password of MySQL, the SQL statement can be executed correctly on the MySQL command line.
Use rpm to install the default directory of MySQL
1. Database directory
/ var/lib/mysql/
2. Configuration file
/ usr/share/mysql (mysql.server commands and configuration files)
3. Related orders
/ usr/bin (mysqladmin mysqldump, etc.)
4. Startup script
/ etc/rc.d/init.d/ (directory of startup script file mysql)
IX. Configure my.cnf file
MySQL 8.0 does not have my.cnf by default, so you can manually create a my.cnf file in the / etc directory, if you initialize the data with the command that specifies the MySQL directory as follows.
Mkdir-p / usr/local/mysqlchown-R mysql.mysql / usr/local/mysqlmysqld-- initialize-- user=mysql-- basedir=/usr/local/mysql-- datadir=/usr/local/mysql/data can configure the my.cnf file as shown below. [client] port = 330 adjust mysql.sock configuration socket = / tmp/mysql.sock [mysqld] # unique number of Mysql services each mysql service Id requires unique server-id = "Service port number default 3306port = 3306#mysql installation root directory basedir = / usr/local/mysql#mysql data file location datadir = / usr/local/mysql/data#pidpid-file = / usr/local/mysql/mysql.pid# setting Directory where the socke file is located socket = / tmp/mysql.sock# set temporary directory tmpdir = / tmp# user user = mysql# allowed access to the IP segment bind-address = 0.0.0." skipping password login # skip-grant-tables# is mainly used for the 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 Note that collation-server = utf8mb4_general_ci# sets the character set when client connects mysql to character-set-server to prevent garbled init_connect='SET NAMES utf8mb4'# from being sensitive to the case of sql statements. 1 means insensitive lower_case_table_names = "maximum number of connections max_connections = 40" maximum number of error connections max_connect_errors = 1000#TIMESTAMP if the declaration NOT NULL is not displayed 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 Must reach this value the number of rows that can be retrieved by logging 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 automatically delete expire_logs_days = 5 after expiration
Summary
The above is the tutorial of CentOS6.8 installation MySQL8.0.18 (RPM way) introduced by Xiaobian to you. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to the website! If you think this article is helpful to you, you are welcome to reprint it, please indicate the source, thank you!
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.