In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to deploy mysql5.7.24 under Centos7.4". In daily operation, I believe many people have doubts about how to deploy mysql5.7.24 under Centos7.4. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "how to deploy mysql5.7.24 under Centos7.4"! Next, please follow the editor to study!
Before installing mysql, you need to configure the environment of the server:
1. Hostname resolution, / etc/hosts configuration
2. JDK environment variable configuration
3. Installation of Mysql5.7.24
I. Environment
Operating system: Centos7.4
Mysql database: mysql-5.7.24-el7-x86_64.tar
JDK:jdk-8u131-linux-x64.tar.gz
First, you need to upload both the Mysql software and JDK to the server.
1. Configure hostname resolution
Vi / etc/hosts
Hostname IP address
For example:
Hostname IP address
Test 192.168.1.10
2. JDK environment configuration
Usually I unpack the software and put it in the / usr/java directory. The java folder needs to be created by myself:
Mkdir / usr/java
Then extract the jdk-8u131-linux-x64.tar.gz to the / usr/java directory
Tar-xzf jdk-8u131-linux-x64.tar.gz-C / usr/java
Set the environment variable / etc/profile file:
Vi / etc/profile
Press I to enter edit mode.
Add the following information to the / etc/profile file:
Export JAVA_HOME=/usr/java/jdk1.8.0_131
Export JRE_HOME=$ {JAVA_HOME} / jre
Export CLASSPATH=.:$ {JAVA_HOME} / lib:$ {JRE_HOME} / lib:$CLASSPATH
Export JAVA_PATH=$ {JAVA_HOME} / bin:$ {JRE_HOME} / bin
Export PATH=$PATH:$ {JAVA_PATH}
Press Esc to exit edit mode and enter: wq to save and close the file.
Load environment variables to take effect: source / etc/profile
View the jdk version. When the jdk version information appears, it indicates that JDK has been installed successfully.
# java-version
Java version "1.8.0141"
Java (TM) SE Runtime Environment (build 1.8.0_141-b15)
Java HotSpot (TM) 64-Bit Server VM (build 25.141-b15, mixed mode)
Second, install mysql
1. Before installing mysql, create a mysql user
Groupadd mysql
Useradd-g mysql mysql
2. Then extract the mysql-5.7.24-el7-x86_64.tar, generate a mysql-5.7.24-el7-x86_64 folder, use the mv command to change its name to mysql, and put it in the / usr/local/ directory.
Mv mysql-5.7.24-el7-x86_64 / usr/local/mysql
3. Establish the data directory, enter the / usr/local/mysql/ directory, and create the data directory
Mkdir data
4. Modify the mysql owner
Using the chown command, the owner of mysql, enter the / usr/local directory and execute the following command
Chown-R mysql:mysql mysql
5. Initialize mysql
First go to the / usr/local/mysql/bin directory and execute the following statement
. / mysqld-user=mysql-basedir=/usr/local/mysql-datadir=/usr/local/mysql/data-initialize
After the execution is completed, it is as follows:
[root@YQHDB2 bin] # / mysqld-- user=mysql-- basedir=/usr/local/mysql-- datadir=/usr/local/mysql/data-- initialize
2019-02-01T08:56:56.506838Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use-explicit_defaults_for_timestamp server option (see documentation for more details).
2019-02-01T08:56:56.856781Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-02-01T08:56:56.913915Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-02-01T08:56:56.973956Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 541f5848-25ff-11e9-800d-000c297c0daa.
2019-02-01T08:56:56.975026Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-02-01T08:56:56.976563Z 1 [Note] A temporary password is generated for root@localhost: fhDQ&DYMn7IW
After the colon on the last line, the login password is automatically generated. Be sure to remember that you will log in to the database later to change the password.
6. Copy the mysql.server file from the support-files directory to the / etc/init.d/ directory, rename it to mysqld, and try to start the mysqld service
Enter the / usr/local/mysql/support-files directory, cp mysql.server / etc/init.d/mysqld, and start the mysqld service using the following command:
Service mysqld start
7. Modify the database password
Log in to the database to change the password:
. / mysql-u root-p
Enter the password given during initialization above, use set password=password ('your password') to modify it, and then log in with the new password.
Handling of problems encountered during deployment:
1. If you want to initialize again, you need to delete all the contents in the data folder using the rm-rf * command, and then initialize it.
2. The mysqld file contains the software installation directory and the data directory, where the software directory is basedir=/usr/local/mysql and the data directory is datadir=/usr/local/mysql/data, which can be adjusted according to your preferences.
3. All error messages are stored in the data directory and in the file with the suffix err.
4 、 [ERROR] Could not create unix socket lock file / var/lib/mysql/mysql.sock.lock.
[ERROR] Unable to setup unix socket lock file.
You need to change the ownership of the mysql under the / var/lib/ directory to mysql. If there is no mysql directory, you need to create it.
5. The my.cnf file is not available in 5.7. here we provide you with a more primitive one under the environment of 5.5. the details are as follows:
Vi / etc/my.cnf
[root@YQHDB2 support-files] # vi / etc/my.cnf
# Example MySQL config file for medium systems.
#
# This is for a system with little memory (32m-64m) where MySQL plays
# an important part, or systems up to 128M where MySQL is used together with
# other programs (such as a web server)
#
# MySQL programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, see:
# http://dev.mysql.com/doc/mysql/en/option-files.html
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.
# The following options will be passed to all MySQL clients
[client]
# password = your_password
Port = 3306
Socket = / var/lib/mysql/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
Port = 3306
Socket = / var/lib/mysql/mysql.sock
Skip-external-locking
Key_buffer_size = 16m
Max_allowed_packet = 1m
Table_open_cache = 64
Sort_buffer_size = 512K
Net_buffer_length = 8K
Read_buffer_size = 256K
Read_rnd_buffer_size = 512K
Myisam_sort_buffer_size = 8m
# Don't listen on a TCP/IP port at all. This can be a security enhancement
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
#
# skip-networking
# Replication Master Server (default)
# binary logging is required for replication
Log-bin=mysql-bin
# binary logging format-mixed recommended
Binlog_format=mixed
# required unique id between 1 and 2 ^ 32-1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
Server-id = 1
# Replication Slave (comment out master section to use this)
#
# To configure this host as a replication slave, you can choose between
# two methods:
#
# 1) Use the CHANGE MASTER TO command (fully described in our manual)-
# the syntax is:
#
# CHANGE MASTER TO MASTER_HOST=, MASTER_PORT=
# MASTER_USER=, MASTER_PASSWORD=
#
# where you replace, by quoted strings and
# by the master's port number (3306 by default)
#
# Example:
#
# CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306
# MASTER_USER='joe', MASTER_PASSWORD='secret'
#
# OR
#
# 2) Set the variables below. However, in case you choose this method, then
# start replication for the first time (even unsuccessfully, for example
# if you mistyped the password in master-password and the slave fails to
# connect), the slave will create a master.info file, and any later
# change in this file to the variables' values below will be ignored and
# overridden by the content of the master.info file, unless you shutdown
# the slave server, delete master.info and restart the slaver server.
# For that reason, you may want to leave the lines below untouched
# (commented) and instead use CHANGE MASTER TO (see above)
#
# required unique id between 2 and 2 ^ 32-1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
# server-id = 2
#
# The replication master for this slave-required
# master-host =
#
# The username the slave will use for authentication when connecting
# to the master-required
# master-user =
#
# The password the slave will authenticate with when connecting to
# the master-required
# master-password =
#
# The port the master is listening on.
# optional-defaults to 3306
# master-port =
#
# binary logging-not required for slaves, but recommended
# log-bin=mysql-bin
# Uncomment the following if you are using InnoDB tables
# innodb_data_home_dir = / var/lib/mysql
# innodb_data_file_path = ibdata1:10M:autoextend
# innodb_log_group_home_dir = / var/lib/mysql
# You can set.. _ buffer_pool_size up to 50-80%
# of RAM but beware of setting memory usage too high
# innodb_buffer_pool_size = 16m
# innodb_additional_mem_pool_size = 2m
# Set.. _ log_file_size to 25% of buffer pool size
# innodb_log_file_size = 5m
# innodb_log_buffer_size = 8m
# innodb_flush_log_at_trx_commit = 1
# innodb_lock_wait_timeout = 50
[mysqldump]
Quick
Max_allowed_packet = 16m
[mysql]
No-auto-rehash
# Remove the next comment character if you are not familiar with SQL
# safe-updates
[myisamchk]
Key_buffer_size = 20m
Sort_buffer_size = 20m
Read_buffer = 2m
Write_buffer = 2m
[mysqlhotcopy]
Interactive-timeout
You only need to copy the above content to the my.cnf file. What parameters are needed can be found on the Internet.
At this point, the study on "how to deploy mysql5.7.24 under Centos7.4" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.