current position:Home>Linux MySQL installation

Linux MySQL installation

2022-06-24 09:06:56Q z1997

Liunx Mysql install

explain :
  Linux There are usually three ways to install the software under : Binary system 、rpm、yum Three ways .
MySQL The download :
   Because I use Alibaba cloud servers , Networked , So I'm directly in linux Download under , Use Windows You can also mysql Download the local file and upload it to the server
Attach the download link of the official website to download the software package in the server through the command line :
Official website : MySQL Download from the official website
Server download ( Connected to the Internet ):wget

Uninstall the original mysql

#  see  
rpm -qa | grep mysql

#  If exist  mysql  The installation files , Is displayed  mysql Installed version information 
#  Such as :mysql-connector-odbc-5.2.5-6.el7.x86_64
#  uninstall 
rpm -e --nodeps mysql-connector-odbc-5.2.5-6.el7.x86_64

Upload and download the installation package

 decompression :tar -zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
 rename :mv mysql-5.7.17-linux-glibc2.5-x86_64 mysql
 Move :mv mysql /usr/local/

Add user group 、 user

groupadd mysql

useradd -g mysql mysql

establish data Directory and change permission

cd /usr/local/mysql
mkdir data
# /usr/local/mysql
chown -R mysql:mysql ./

To configure my.cnf

[root etc]# pwd
[root etc]# touch my.cnf
#  Set up mysql Client default character set 
#mysql Login without password 
# Ban DNS analysis 
#  port 
#  Set up mysql Installation directory 
#  Set up mysql Database data storage directory 
#  Maximum connections allowed 
#  The default character set used by the server 
#  The default storage index that will be used when creating a new table 

initialization mysql

./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data 

# After execution, it will output : The red one is the initial password
 Insert picture description here

Set up mysql To start the machine automatically

   # Copy mysql.server To init.d Under the table of contents 

    cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
    chmod +x /etc/rc.d/init.d/mysqld

    # Add service 

    chkconfig --add mysqld

    # See if it is added successfully 

    chkconfig --list mysqld 

 Insert picture description here

Configure environment variables

vi /etc/profile

# Add the following 
export PATH
# Make configuration effective 
source /etc/profile
# Check whether the configuration is effective 
echo $PATH

First login changes password

alter user ' user name '@'localhost | %' identified by  ' password ';

alter user 'root'@'localhost' identified by  'Daxizi7724530!'; 

copyright notice
author[Q z1997],Please bring the original link to reprint, thank you.

Random recommended