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

MySQL 5.7deployment classification

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article mainly introduces the MySQL 5.7deployment classification, which involves things, learned from the theoretical knowledge, there are many books and literature for your reference, in practical sense, accumulated years of practical experience can be shared with you.

MySQL5.7 deployment can be divided into rpm package deployment, source package deployment, and binary package deployment.

Source package deployment: the advantage is high flexibility, custom compilation parameters, high efficiency, but the disadvantage is long deployment time.

Binary package deployment: the advantage is that it has been compiled in advance, the deployment is fast, and some parameters can be customized, but the disadvantage is that it takes longer to install than using yum.

Rpm package deployment: the advantage is fast deployment, but the disadvantage is poor customization.

When there are generally no special requirements, you can use the yum package to deploy

Let's start using binaries to deploy MySQL5.7.26 binaries

Download address: https://dev.mysql.com/downloads/mysql/5.7.html#downloads

Select "Linux Generic" in the Select Operating System option, and download the download after the TAR entry in the bottom Linux-Generic (glibc 2.12) (x86, 64-bit).

1. Add users and user groups running in the MySQL database

Groupadd-r mysqluseradd-r-g mysql mysql

two。 The directory for this MySQL deployment is / application, extract the MySQL installation package to the / application/mysql-5.7.26-linux-glibc2.12-x86_64 directory, and create a soft link for this directory

Ln-s / application/mysql-5.7.26-linux-glibc2.12-x86_64 / application/mysql

Change directory permissions

Chown-R mysql:mysql / application/mysql-5.7.26-linux-glibc2.12-x86_64

3. Initialize the database

/ application/mysql-5.7.26-linux-glibc2.12-x86_64/bin/mysqld-initialize-user=mysql-basedir=/application/mysql-datadir=/application/mysql/data [root@chanye application] # / application/mysql-5.7.26-linux-glibc2.12-x86_64/bin/mysqld-initialize-user=mysql-basedir=/application/mysql-datadir=/application/mysql/data2019-06-18T08:35:49.103727Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use-- explicit_defaults_for_timestamp server option (see documentation for more details). 2019-06-18T08:35:49.885283Z 0 [Warning] InnoDB: New log files created, LSN=457902019-06-18T08:35:49.944856Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.2019-06-18T08:35:50.002905Z 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: 138aa81a-91a4-11e9-8f49-005056813525.2019-06-18T08:35:50.004044Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.2019-06-18T08:35:50.004493Z 1 [Note] A temporary password is generated for root@localhost: Oteria SA6z > SieK

Remember the temporary password for the last line

4. Create RSA private key

/ application/mysql/bin/mysql_ssl_rsa_setup-- datadir=/application/mysql/dataGenerating a 2048 bit RSA private key.+++ .... + writing new private key to 'ca-key.pem'-Generating a 2048 bit RSA private key..+++.+++writing new private key to' server-key.pem'-Generating a 2048 bit RSA private key.. .. + +. . + writing new private key to 'client-key.pem'

5. Add mysql to boot self-boot

Cp / application/mysql-5.7.26-linux-glibc2.12-x86_64/support-files/mysql.server / etc/init.d/mysqld

Modify basedir and datadir in / etc/init.d/mysqld

46 basedir=/application/mysql 47 datadir=/application/mysql/data

Join the boot self-boot

Chkconfig mysqld onchkconfig-list mysqldNote: This output shows SysV services only and does not include native systemd services. SysV configuration data might be overridden by native systemd configuration. If you want to list systemd services use 'systemctl list-unit-files'. To see services enabled on particular target use 'systemctl list-dependencies [target]'. Mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Modify the global configuration file to add the mysql executable path to PATH, and add on the last line of / etc/profile:

Export PATH=/application/mysql/bin:$PATH

Use source / etc/profile to make the configuration effective

Delete the / etc/my.cnf or rename that comes with the system, create a new my.cnf in the / application/mysql/ directory, and adjust the file attribute to mysql:mysql

[mysqld] character-set-server=utf8datadir=/application/mysql/datasocket=/application/mysql/mysql.sock# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0# Settings user and group are ignored when systemd is used.# If you need to run mysqld under a different user or group # customize your systemd unit file for mariadb according to the# instructions in http://fedoraproject.org/wiki/Systemd## include all files from the config directory#!includedir / etc/ my.cnf.d[client] character-set-server=utf8socket=/application/mysql/mysql.sock [mysql] character-set-server=utf8socket=/application/mysql/mysql.sock

6. Start mysql

Start mysql

/ etc/init.d/mysqld start

Use the password provided by initialization to log in at this time

# mysql-uroot-pEnter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket'/ tmp/mysql.sock' (2)

The mysql.sock file used by the default client of the system is based on unix sock, so the easiest way to do this is to create a soft link

Ln-s / application/mysql/mysql.sock / tmp/mysql.sock

If you do not create a soft link, use the-S option when logging in with the mysql command, and you can also log in by manually specifying the location of the mysql.sock.

You need to change the administrator password after a successful login

Alter user 'root'@'localhost' identified by' 598545$ kdOctamvsU';flush privileges

View mysql status

Mysql > status;-mysql Ver 14.14 Distrib 5.7.26, for linux-glibc2.12 (x86 / 64) using EditLine wrapperConnection id: 4Current database: Current user: root@localhostSSL: Not in useCurrent pager: stdoutUsing outfile:''Using delimiter: Server version: 5.7.26 MySQL Community Server (GPL) Protocol version: 10Connection: Localhost via UNIX socketServer characterset: utf8Db characterset: utf8Client characterset: utf8Conn. Characterset: utf8UNIX socket: / application/mysql/mysql.sockUptime: 7 min 56 secThreads: 2 Questions: 14 Slow queries: 0 Opens: 116 Flush tables: 1 Open tables: 109 Queries per second avg: 0.029

-

After reading the above introduction of MySQL 5.7 deployment classification, I hope it can bring some help to you in practical application. Due to the limited space in this article, there will inevitably be deficiencies and areas that need to be supplemented. You can continue to pay attention to the industry information section and will update your industry news and knowledge regularly. If you need more professional answers, you can contact us on the official website for 24-hour pre-sales and after-sales to help you answer questions at any time.

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