In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Configuration description
Linux system: CentOS-7.0
MySQL version: 5.7.21
It is known that there are two ways to start multiple MySQL instances under the Linux system, one is through the official mysqld_multi.server, but I haven't studied how to do it yet; the other is through the original method of installing multiple MySQL servers. I am now doing this in the second way. 2 MySQL instances were started successfully. Next, we will introduce the operation process. Please give us more advice.
Install the first MySQL (5.7.21) server
First of all, let me explain that I installed mysql with a binary package: mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz
1. Get the mysql binary package, then extract it with the tar command, rename the extracted folder to a shorter name with the mv mysql-5.7.21-linux-glibc2.12-x86_64 mysql_3306 command, and note the port number to be used for easy distinction. As for where to put the extracted files, you decide for yourself, the difference is that if you don't name the extracted files mysql and put them directly into the / usr/local directory, or use mysql references in the / usr/local directory through ln, you need to specify in the my.cnf or startup command parameters (the actual path to basedir= files and the actual path to datadir= graduation files / data). This description is actually in mysql.server, you can use the vi command to open it and have a look.
2. After reading many descriptions of mysql installation methods on the Internet, we will mention new user groups and users: groupadd mysql and useradd-r-g mysql-s / bin/false mysql, and add mysql users and mysql user groups. This depends on your own actual needs, because I am for my own use, there is no security problem, there is no new, but directly use root. If you need to add new users and user groups, you can find information online or see it in MySQL's official manual: https://dev.mysql.com/doc/refman/5.7/en/binary-installation.html
3. Create a new my.cnf or copy a copy from elsewhere, mainly by specifying parameters such as basedir, datadir, port number and socket in the initialization file. The following figure is my my.cnf content. Please replace the relevant parameters according to your actual path and put them in the installation directory:
4. According to the installation steps of the official document, you also need to create a new mysql-files folder under the installation directory. I don't know exactly why you want to create this folder. Haha, give the content of the official document "The mysql-files directory provides a convenient location to use as the value for the secure_file_priv system variable, which limits import and export operations to a specific directory."
5. Initialize mysql, first add the data folder under the installation directory, then go to the bin folder of the installation directory, and execute the following command: ". / mysqld-- initialize-- user=root-- basedir=/data/program/mysql3306-- datadir=/data/program/mysql3306/data". In linux, when a command takes a parameter, two horizontal bars "-" are used if the parameter name is full, and if the parameter is abbreviated, a horizontal bar "-" is used, such as. / mysql-- host=localhost and. / mysql-hlocalhost. In the above command to initialize mysql, replace the parameter values with your own path and user. If you install only one mysql and are in the default directory / usr/local/mysql, you don't need to specify the basedir and datadir parameters. If you want to reinitialize for some reason, then you need to delete the contents of the data directory first, you can choose to delete the entire data folder and add: rm-rf data, mkdir data, and then you execute the above initialization command, you can reinitialize smoothly. It should be noted here that after successful initialization, the default password will be found at the end of the prompt. Be sure to remember it and use it when the client logs in later.
6. Next, create the certificate and key needed for secure transfer, and execute the command ". / mysql_ssl_rsa_setup-- datadir=/data/program/mysql3306/data" in the bin directory. Similarly, replace the parameter with your value. The default installation directory does not need to specify the datadir value. The official function of this command is as follows: "This program creates the SSL certificate and key files and RSA key-pair files required to support secure connections using SSL and secure password exchange using RSA over unencrypted connections, if those files are missing." it probably means that this command creates the SSL certificate and key,RSA key-value pairs required for secure transmission over unencrypted connections using SSL and RSA.
7. At this point, the initialization of mysql is complete, and you can start the mysql server. After version 5.7, it seems that the service is started using the mysqld_safe command, or you can start the service using mysql.server under the support-file directory, but mysql.server is also started using mysqld_safe. The command for mysqld_safe is as follows: ". / mysqld_safe-- defaults-file=/data/program/mysql3306/my.cnf-- user=root-- port=3306 &", the key is to specify the my.cnf path, because I am not installed in the default directory, and we are going to install two mysql on one machine. It should be noted that "- defaults-file" must be the first parameter, otherwise an error will be reported and there will be a corresponding prompt; another is the "&" at the end of the command, which tells the system to use the mysql instance as a background process, so that the mysql server can continue to run when you exit the command.
For more information about the parameters of the mysql_safe command, please see: https://www.jb51.net/article/52259.htm
8. After starting the server, you can use the client to access the server, execute the command under the bin directory: ". / mysql-uroot-P3306-p", and then prompt for the password, then you enter the default password in step 5. Once inside, set your new password by set password=password ('new password'), otherwise the server won't let you do anything else.
9. At this point, an installation of mysql has been completed.
Second, install the nth MySQL (5.7.21) server
With the above installation process, basically the nth mysql installation is the same as above, extract the installation package, rename it to mysql_port, distinguish different mysql servers by port number, and then replace the parameters about the path with the corresponding path in my.cnf and the command executed above. By setting a specific path, you can install and start multiple mysql instances under one linux machine. When the client accesses the server, you need to determine which port, with the parameter-P3306, uppercase P.
This is only a simple installation process of recording and learning, mysql still has a lot of configuration and features to pay attention to, later have the opportunity to sort it out.
Summary
The above is the whole content of this article, I hope that the content of this article has a certain reference and learning value for your study or work, if you have any questions, you can leave a message and exchange, 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.