Linux operations learning in binary format installation

Source: Internet
Author: User

this week is about MySQL's binary format installation, we generally have two ways to install MySQL, one is through Yum installation, the second is the installation in binary format, the first method of 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 limited, software version restrictions, we can only passively use, and if we use the binary format installation can specify where the database files are placed, configuration files are also made by ourselves, for flexible use, There is a new version of the use, there is an inconvenient way to install, that is, you manually compile the installation, because the MySQL file is actually quite large, after the compilation may be more than 10G, and the compilation also takes a lot of time, so we put someone else compiled binary files to come 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 setting its login mode for/sbin/nologin, to specify its home directory as/APP/MYSQLDB, my/app is a special new folder, because our database files will be placed here, in the production environment , the database in this folder is getting bigger and larger, and if we are using LVM logical volume, we can extend it, and use the normal partition as far as possible to select a larger folder, the new user code is as follows:

useradd-d/app/mysqldb-r-m-s/sbin/nologin MySQL

We need to get the mariadb-10.2.8-linux-x86_64.tar.gz in https://downloads.mariadb.org/and extract it to the specified directory/usr/local/, which is a fixed directory, cannot be changed, but we switch to this directory, in order to facilitate us to link the directory as/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 doing this we looked at, in/etc there is no related configuration of MySQL, so we need to complete the configuration file ourselves, the new MySQL directory is for easy management, after all, etc files many, find our new file [mysqld] 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 #指定数据库的目录innodb_file_per_table = on #将每个表都放在单独的文件夹中skip_name_resolve = on #禁止主机名解析 ( Do not close, will cause the database to run slowly)

Then we started to specify the installation, we are still under the/usr/local/mysql/, why to install it, because someone else in the compilation script has been written dead, so we in this relative path, can be installed successfully

scripts/mysql_install_db--user=mysql--datadir=/app/mysqldb

After the installation, in order to make our later use more convenient, so we need to do the following:

CP support-files/mysql.server/etc/init.d/mysqldchkconfig--list mysqld #查看chkconfig中是否有我们的mysqldchkconfig--add mysq LD #添加mysqld进入chkconfigservice mysqld start #启动mysqld the same way as the system, but this step is doomed to fail.

What is the reason for failure? The log file is missing, or the log does not have read and write permissions, so we want to change the owner of the folder or use the ACL, for the sake of simplicity, I used the way to change the owner:

Mkdir/var/log/mariadb/chown mysql/var/log/mariadb/service mysqld Start #启动成功

Then we need to modify the execution path because we can't use all the paths, and that's stupid.

Vi/etc/profile.d/mysql.sh #写入文件, can also be effective in the future Path=/usr/local/mysql/bin: $PATH #增加到PATH中. /etc/profile.d/mysql.sh #source一下, effective.

and then our MySQL is finished, why is it counted? Because of security risks:after the installation of MySQL, there is a security risk, no matter what identity as long as in the local, you can log in with the root of MySQL,mysql can be anonymous link, but not the right, but also a small security risks

Solve:

/usr/bin/mysql_secure_installation

This script is interactive, but it is very simple, we close the anonymous login inside, and set the password to ensure the further security of MySQL, but the next time you log in, you need to enter a password;

Mysql-uroot-p #-u[user] [-hhost] do not write default native login-p[passwd] is the password

so far our MySQL binary installation is complete, and then you can use it happily!



Linux operations learning in binary format installation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.