In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
What we will bring you this week is about the installation of mysql in binary format. We generally have two ways to install mysql, one is through yum installation, the other is through binary format installation. The first method, yum installation, is very simple, as follows:
Centos6:yum install mysql-server Centos7:yum instlal mariadb-server
But the simple behind is a variety of restrictions, database files are limited, configuration files are also limited, software version restrictions, we can only use passively, and if we use binary format installation, we can specify where the database files are placed, and the configuration files are made by ourselves, which is conducive to flexible use, the use of new versions, and an inconvenient way of installation. That is to compile and install manually, because the mysql file is actually quite large, it may be more than 10G after compilation, and it takes a lot of time to compile, so we take the binaries compiled by others to install. This experiment is based on Centos7, and the installation package is mariadb-10.2.8-linux-x86_64.tar.gz.
First of all, we need to create a new mysql user. For security settings, the login method is / sbin/nologin, and the home directory is specified as / app/mysqldb. My / app is a newly created folder, because our database files will be placed here in the future. In the production environment, the database in this folder will become larger and larger. If we are using lvm logical volumes, we can also expand it. For the ordinary partition, choose a larger folder as far as possible. The new user code is as follows:
Useradd-d / app/mysqldb-r-m-s / sbin/nologin mysql
We need to get mariadb-10.2.8-linux-x86_64.tar.gz in https://downloads.mariadb.org/, and then extract it to the specified directory / usr/local/,. This is a fixed directory and cannot be changed, but we switch to this directory. To make it easier for us to link this directory to / mysql
Tar xvf mariadb-10.2.8-linux-x86_64.tar.gz-C / usr/local/cd / usr/local/ln-s mariadb-10.2.8-linux-x86_64/ mysql
After we have done this, we checked that there is no relevant configuration of mysql under / etc, so we need to complete the configuration file by ourselves. A new mysql directory is built for ease of management. After all, there are many files under / etc. Find the bottom of [mysqld] in our new file and add the three lines of code we need.
Mkdir / etc/mysql/ cd / usr/local/mysql/ cp support-files/my-huge.cnf / etc/mysql/my.cnfvim / etc/mysql/ my.cnf [mysqld] datadir = / app/mysqldb # specify the directory of the database innodb_file_per_table = on # put each table in a separate folder skip_name_resolve = on # disable hostname resolution (do not close, it will cause the database to run slowly)
Then we start to specify the installation, and we are still under / usr/local/mysql/. Why install it this way? because someone else is already dead in the compilation script, so we can install successfully under this relative path.
Scripts/mysql_install_db-user=mysql-datadir=/app/mysqldb
After installation, in order to make it more convenient for us to use in the future, we need to do the following:
Cp support-files/mysql.server / etc/init.d/mysqldchkconfig-- list mysqld # check whether there is our mysqldchkconfig in chkconfig-- add mysqld # add mysqld into chkconfigservice mysqld start # start mysqld in the same way as system applications, but this step is doomed to failure
What is the reason for the failure? The log file is missing, or there is no read and write access to the log, so we want to change the owner of the folder or use ACl. For simplicity, I used the method of changing the owner:
Mkdir / var/log/mariadb/chown mysql / var/log/mariadb/service mysqld start # started successfully
Then we need to modify the execution path, because we can't use it to type out all the paths, which is stupid.
Vi / etc/profile.d/mysql.sh # is written to the file, and PATH=/usr/local/mysql/bin:$PATH # can be added to PATH later. / etc/profile.d/mysql.sh # source, effective.
Then our mysql is finished, why count it? Because of security risks: after mysql installation, there are security risks. No matter what identity is on the local machine, you can log in to mysql,mysql with root and you can link anonymously, but the authority is small, and it is also a small security hazard.
Resolve:
/ usr/bin/mysql_secure_installation
This script is interactive, but it is very simple. We can ensure the further security of mysql by turning off anonymous login and setting the password, but we need to enter the password the next time we log in.
Mysql-uroot-p #-u [user] [- hhost] does not write default native login-p [PASSWD] is the password
At this point, the binary installation of our mysql is complete, and then you can use it happily!
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.