Install mysql stand-alone version

Install mysql stand-alone version

Ready to work

The Linux version used is centos 7, for convenience, first turn off the firewall and configure the network. In the installation part, it will be divided into two parts. First, we will talk about single-instance installation, that is, install a mysql on a server, and then Multi-instance installation, install 2 or more mysql on one server.

Single instance installation

cp /soft/mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz /usr/local/

Source code package sharing
Extraction code: upwi
unzip mysql to /usr/local directory
Unzip:

 tar -zxvf mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz

Install the required dependencies

yum install -y libaio

Specific installation

shell> groupadd mysql 
shell> useradd -r -g mysql mysql 
shell> cd /usr/local 
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz 
shell> ln -s full-path-to-mysql-VERSION-OS mysql 
shell> cd mysql shell> mkdir mysql-files 
shell> chmod 770 mysql-files 
shell> chown -R mysql . 
shell> chgrp -R mysql . 
shell> bin/mysqld --initialize --user=mysql # MySQL 5.7.6 and up 
shell> bin/mysql_ssl_rsa_setup # MySQL 5.7.6 and up 
shell> chown -R root . 
shell> chown -R mysql data mysql-files 
shell> bin/mysqld_safe --user=mysql & 
# Next command is optional 
shell> cp support-files/mysql.server /etc/init.d/mysql.server

ps: bin/mysqld --initialize --user=mysql
This step needs attention, because mysql will load
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/ .my.cnf is
scanned in this order. At this time, we already have my.cnf in the etc directory,
but because there is no permission, an error will be reported, so we logically delete it

mv /etc/my.cnf my.cnfbak

Insert picture description here

Insert picture description here
Then continue to execute the above commands in order.
After the execution is successful, the data will be out of the data file
Insert picture description here
Insert picture description here

Set mysql to start automatically

 cp support-files/mysql.server /etc/init.d/mysql.server

View auto-start commands

 chkconfig --list

mysql self-start

chkconfig mysql.server  on

Configure environment variables

vim /etc/profile

Add the last line:

export PATH=/usr/local/mysql/bin:$PATH

Application environment variables

source /etc/profile

Log in to mysql

mysql]# mysql -uroot -p

The password is the value of the execution of this statement (different each time)
Insert picture description here
after login-change the password

set password = 'root1234%';

Allow remote login

grant all on *.* to root@'%' identified by 'root1234%' with grant option;

refresh

flush privileges;

Guess you like

Origin blog.csdn.net/weixin_42292697/article/details/113992689