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

How to install and configure MySQL 8.0 under Linux

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article is about how to install and configure MySQL 8.0 under Linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

1. Compile and install MySQL8.0

Version information

# cat / etc/redhat-release CentOS Linux release 7.5.1804 (Core)

Install dependency packages

Yum-y install wget cmake gcc gcc-c++ ncurses ncurses-devel libaio-devel openssl openssl-devel rpm-qa | grep libaio yum install libaio libaio-devel

Download the source package

Wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-boost-8.0.12.tar.gz

Create users and establish data directories and grant users directory permissions

Groupadd mysql useradd-r-g mysql-s / sbin/nologin mysql mkdir-p / usr/local/mysql mkdir-p / data/mysql chown-R mysql.mysql / usr/local/mysql chown-R mysql.mysql / data/mysql chmod-R 755 / usr/local/mysql/ chmod-R 755 / data/mysql/

Unpack and start installation

Tar-zxf mysql-boost-8.0.12.tar.gz

Configuration

Cd mysql-8.0.12 cmake. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql\-DMYSQL_DATADIR=/data/mysql\-DSYSCONFDIR=/etc\-DMYSQL_TCP_PORT=3306\-DWITH_BOOST=~/mysql-8.0.12/boost\-DDEFAULT_CHARSET=utf8\-DDEFAULT_COLLATION=utf8_general_ci\-DENABLED_LOCAL_INFILE=ON\-DWITH_INNODB_MEMCACHED=ON\-DWITH_INNOBASE_STORAGE_ENGINE=1\-DWITH_FEDERATED_STORAGE_ENGINE=1\-DWITH_BLACKHOLE_STORAGE_ENGINE=1\-DWITH_ARCHIVE _ STORAGE_ENGINE=1\-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1\-DWITH_PERFSCHEMA_STORAGE_ENGINE=1

Configuration parameters description:

CMAKE_INSTALL_PREFIX: specify the base installation directory

MYSQL_DATADIR: specify the data directory

SYSCONFDIR=/etc: specifies the profile scan directory

MYSQL_TCP_PORT: specify the port number

WITH_BOOST: specify the directory where the boost is located

DEFAULT_CHARSET: specify the default character set

DEFAULT_COLLATION: specify default collation

ENABLED_LOCAL_INFILE=ON: whether to enable local for load data infile

WITH_INNODB_MEMCACHED=ON: whether to generate memcached shared libraries

Compile & install

Make & & make install

Initialize the database

Mysqld-initialize-insecure-user=mysql-basedir=/usr/local/mysql-datadir=/data/mysql

Establish a configuration file

Cat > / etc/my.cnf / etc/profile source / etc/profile

Configure startup script

Cp.. / mysql-8.0.12/support-files/mysql.server / etc/init.d/mysqld vim / etc/init.d/mysqld chmod + x / etc/init.d/mysqld / etc/init.d/mysqld start

Centos7 system self-startup script

Cat / usr/lib/systemd/system/mysqld.service [Unit] Description=mysql server daemon Documentation=man:mysql (8) Documentation= http://dev.mysql.com/doc/refman/en/using-systemd.html After=network.target After=syslog.target [Install] WantedBy=multi-user.target [Service] User=mysql Group=mysql Type=notify TimeoutSec=0 PermissionsStartOnly=true ExecStart=/usr/local/mysql/bin/mysqld $MYSQLD_OPTS LimitNOFILE = 10000 Restart=always RestartPreventExitStatus=1 Environment=MYSQLD_PARENT_PID=1 PrivateTmp=false

Start MySQL

Systemctl start mysqld.service

Modify root password: use WITH to specify authentication method

Mysql-uroot ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY'; ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY' your password

View password fields and encryption methods

Select host, user, authentication_string, plugin from user

2. Install MySQL for yum repository

Wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm yum localinstall mysql80-community-release-el7-1.noarch.rpm yum repolist enabled | grep "mysql.*-community.*" yum repolist all | grep mysql yum install mysql-community-server systemctl enable mysqld systemctl start mysqld netstat-lntup | grep 3306

View randomly generated passwords

Grep 'temporary password' / var/log/mysqld.logmysql-uroot-p

To change the password, the password must consist of uppercase and lowercase letters, numbers, and characteristic characters

Alter user 'root'@'localhost' identified by' PJY@123.com';select version (); Thank you for reading! This is the end of this article on "how to install and configure MySQL 8.0 under Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

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

Servers

Wechat

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

12
Report