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 precompiled package installation configuration

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

Share

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

System environment: CentOS 7.6

Turn off security mechanisms such as firewalls

Check whether the system has a database installed by default

[root@mysqlmaster ~] # rpm-qa | grep mariadb

Mariadb-libs-5.5.56-2.el7.x86_64

Uninstall the default database

[root@mysqlmaster] # rpm-e mariadb-libs-5.5.56-2.el7.x86_64-- nodeps

Download precompiled binary package

[root@mysqlmaster ~] # wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz

Decompression package

[root@mysqlmaster] # tar fx mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz-C / usr/local

Rename mysql or create a soft connection

[root@mysqlmaster ~] # mv / usr/local/mysql-5.7.18-linux-glibc2.5-x86_64/ / usr/local/mysql

Create a soft connection (no need to create a soft connection if renamed)

[root@mysqlmaster] # ln-s / usr/local/mysql-5.7.18-linux-glibc2.5-x86_64/ / usr/local/mysql

Create users and groups

[root@mysqlmaster ~] # groupadd mysql

[root@mysqlmaster] # useradd-r-g mysql mysql

Write a configuration file for mysql

[root@mysqlmaster ~] # vim / etc/my.cnf

[mysqld]

Datadir=/usr/local/mysql/data

Socket=/usr/local/mysql/mysql.sock

Symbolic-links=0

[mysqld_safe]

Log-error=/usr/local/mysql/logs/error.log

Pid-file=/usr/local/mysql/mysql.pid

[client]

Socket=/usr/local/mysql/mysql.sock

Immediately after the configuration file is written, create the path mentioned in the configuration file.

[root@mysqlmaster] # mkdir-p / usr/local/mysql/data

[root@mysqlmaster] # mkdir-p / usr/local/mysql/logs

[root@mysqlmaster ~] # touch / usr/local/mysql/logs/error.log

Authorization

[root@mysqlmaster] # chown-R mysql.mysql / usr/local/mysql/

[root@mysqlmaster] # chown-R mysql.mysql / etc/my.cnf

Installation

[root@mysqlmaster] # / usr/local/mysql/bin/mysqld-initialize-insecure-user=mysql-basedir=/usr/local/mysql/-datadir=/usr/local/mysql/data/

Do some extra security reinforcement.

[root@mysqlmaster] # / usr/local/mysql/bin/mysql_ssl_rsa_setup-- basedir=/usr/local/mysql/-- datadir=/usr/local/mysql/data/

Copy startup script

[root@mysqlmaster ~] # cp / usr/local/mysql/support-files/mysql.server / etc/init.d/mysqld

Modify a file

[root@mysqlmaster] # sed-I '46c basedir=/usr/local/mysql' / etc/init.d/mysqld

[root@mysqlmaster ~] # sed-I '47c datadir=/usr/local/mysql/data' / etc/init.d/mysqld

[root@mysqlmaster ~] # sed-I '63c mysql_pid_file_path=/usr/local/mysql/data/mysqld.pid' / etc/init.d/mysqld

Start the database

[root@mysqlmaster ~] # / etc/init.d/mysqld start

Database started successfully!

Set up a soft connection to facilitate startup

[root@mysqlmaster] # ln-s / usr/local/mysql/bin/* / usr/local/sbin/

Change the password (five interactive high-end change password), and log in successfully!

[root@mysqlmaster] # mysql-e "use mysql;alter user 'root'@'localhost' identified by' 123456;"

[root@mysqlmaster] # mysql-uroot-p123456

Join systemctl to manage

Cat > / usr/lib/systemd/system/mysqld.service

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