Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Binary installation mysql 5.7and mariadb (with yum installation mode)

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Foreword:

This article takes mariadb as an example, installs mysql in the same way, and passes the test. Look for the relevant packages installed on the system (rpm-qa | grep-e "mysql"-e "mariadb") and uninstall them before installation.

1. Prepare the directory where mariadb stores the database files.

Mkdir-p / mydata/datachown mysql:mysql data # if there are no mysql users and groups need to create new system users, group example: # groupadd-r-g 306 mysql # if you need to specify a group, you need to establish a group before you specify it, for example-g 306useradd-r-M-s / sbin/nologin mysql

Database files take up a large amount of memory, so it is recommended to put them on logical volumes to ensure scalability. The following is the process of configuring logical volumes. If not, you can skip the following steps and go directly to step 2.

① configures logical volume partitions or new hard drives

② creates logical volume lv

③ uses xfs file system logical volumes to be scalable, because Centos 6 does not support xfs file systems by default, with the help of the software xfsprogs.

Yum install xfsprogs-y # install xfsprogsmodprobe xfs # load xfs file system driver mkfs.xfs / dev/myvg/mydata # create a file system

④ mounts the xfs file system

Vim / ETC hand FSTABVOR ritual blkid / dev/myvg/mydata UUID=1a5a90a2-2559-494f-954a-7177911e3535 / mydata xfs defaults 00 mount-a

2. Configure and install mariadb

① go to the official website to download the mariadb binary installation package https://downloads.mariadb.org/ Centos 6 system it is recommended to install version 5 stable version, do not install more than 10 version. This article takes the installation of mariadb-5.5.57-linux-x86_64.tar.gz as an example.

Tar xvf mariadb-5.5.57-linux-x86_64.tar.gz-C / usr/local # extract to / usr/localcd / usr/localln-sv mariadb-5.5.57-linux-x86_64/ mysql # to create a soft connection chown-R root:mysql mysql/ # Recursively modify the file to belong to the master group

② prepares configuration file

Configuration format: ini-like format, each program is provided by a single configuration file with [prog_name]

Configuration file lookup order: overwrite the previous configuration file

/ etc/my.cnf-> / etc/mysql/my.cnf-- >-- default-extrafile=/PATH/TO/CONF_FILE-- > ~ / .my.cnf

Mkdir / etc/mysqlcp / usr/local/mysql/support-files/my-large.cnf / etc/mysql/my.cnf # copy the template configuration file to / etc/mysql and rename it to my.cnfvim / etc/mysql/my.cnf find [mysqld] add the following configuration datadir = / mydata/datainnodb_file_per_table = on # to use the innodb engine, a separate database for each table skip_name_resolve = on # forbids host name resolution Speed up lower_case_table_names = 1 # ignore form case character-set-server=utf8mb4 # set the default character to utf8mb4 optional configuration example: basedir = / usr/local/mysql#socket = / tmp/mysql.sock # if the custom socket location needs to be configured at the same time in the [client] section, port should also be configured. Otherwise, there may be an error pid-file = / data/mysqldata/ mysql.pid [mysqld _ safe] # you need to manually create logs/error.log and change it to mysql owner log-error = / mydata/data/error.log

③ creates database files

The locations of different versions of cd / usr/local/mysql # are different. Some scripts/mysql_install_db-- user=mysql-- datadir=/mydata/data # under the bin directory. Be careful not to enter the scripts directory for execution. The new method is about to be abandoned as follows: mysqld-initialize-- user=mysql-- basedir=/usr/local/mysql-- datadir=/home/mysql if-initial-insecure is added during initialization, an root@localhost account with an empty password will be created. Otherwise, a root@localhost account with password will be created.

④ prepares the service script and starts the service

Cp support-files/mysql.server / etc/init.d/mysqld # copy service script and rename mysqldchkconfig-- add mysqldchkconfig mysqld on # set to boot

⑤ join executable path

Vim / etc/profile.d/mysql.shexport PATH=/usr/local/mysql/bin:$PATH. / etc/profile.d/mysql.sh

⑥ security initialization

/ user/local/mysql/bin/mysql_secure_installation # configure root password, delete anonymous users, etc.

⑦ prepares the log file and starts the service

Touch / var/log/mysqld.logtouch / mydata/data/error.logchown mysql / var/log/mysqld.log chown mysql / mydata/data/error.logservice mysqld start

Installation complete!

If you encounter an error ERROR 2002 (HY000): Can't connect to local MySQL server through socket'/ tmp

Edit my.cnf

[client] socket = / tmp/mysql.sock # settings are the same as those set in the mysqld section or ln-s / var/lib/mysql/mysql.sock / tmp/mysql.sock

Yum installation method:

In this way, you can install each version of mysql. On this page, https://dev.mysql.com/downloads/repo/yum/ downloads the corresponding system repo file installation package.

Example:

Centos7 https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm

Centos6 https://dev.mysql.com/get/mysql80-community-release-el6-1.noarch.rpm

After downloading and installing, go to / etc/yum.repos.d/ to edit mysql-community.repo. The latest version is enabled by default. Edit the latest version of enabled=0 and change the version you want to install to 1. After that, yum install mysql-server can complete the installation. If you need to install multiple times, download the corresponding mysql-server package, and then install it, for example, yum localinstall mysql-community-server-5.7.23-1.el7.x86_64.rpm.

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report