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 http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

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
pwd
# /usr/local/mysql
chown -R mysql:mysql ./

To configure my.cnf

[root etc]# pwd
/etc
[root etc]# touch my.cnf
[mysql]
#  Set up mysql Client default character set 
default-character-set=utf8
socket=/tmp/mysql.sock
 
 
[mysqld]
 
#mysql Login without password 
#skip-grant-tables
 
# Ban DNS analysis 
#skip-name-resolve
#  port 
port=3306
socket=/tmp/mysql.sock
#  Set up mysql Installation directory 
basedir=/usr/local/mysql
#  Set up mysql Database data storage directory 
datadir=/usr/local/mysql/data
#  Maximum connections allowed 
max_connections=200
#  The default character set used by the server 
character-set-server=utf8
#  The default storage index that will be used when creating a new table 
default-storage-engine=INNODB
#lower_case_table_name=1
max_allowed_packet=16M

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 
PATH=$PATH:/usr/local/mysql/bin
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.
https://en.cdmana.com/2022/175/202206240625360379.html

Random recommended