Install MySQL on Linux system and connect mysql on the host (detailed)

All filenames in this article are just identifiers, and the specific content is written according to the specific situation!!
All filenames in this article are just identifiers, and the specific content is written according to the specific situation!!
All filenames in this article are just identifiers, and the specific content is written according to the specific situation!!

**

Preparation before installation

**
Check if mysql is installed

rpm -qa | grep mysql

Remove if installed

rpm -e --nodeps fileName
//or
yum remove fileName

Execute again to see if it is deleted

rpm -qa | grep mysql

Query the folder corresponding to mysql

whereis mysql
find / -name mysql

Delete related directory or file

rm -rf fileName

Check whether mysql user group and user exist, if not, create

cat /etc/group | grep mysql
cat /etc/passwd |grep mysql
groupadd mysql
useradd -r -g mysql mysql

Download MySQL installation package for Linux on the official website

wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz

Or go MySQL official website , select the corresponding version to download.
**

Install mysql

**
1. Decompress the downloaded compressed package

tar -zxvf  mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz

2. Move the file to / usr/local /, and change the folder name to mysql. If there is no mysql folder under / usr/local /, execute the following command directly

mv mysql-5.7.24-linux-glibc2.12-x86_64 /usr/local/mysql


If there is a mysql folder under / usr/local /, switch to the usr/local directory and change the existing mysql file to another name.

cd /usr/local/
mv mysql newFileName

Execute after modification

cd Uncompressed directory
mv mysql-5.7.24-linux-glibc2.12-x86_64 /usr/local/mysql

3. Create data directory in / usr/local/mysql directory

mkdir /usr/local/mysql/data

4. Change the user groups, users and permissions of all directories and folders under mysql directory

chown -R mysql:mysql /usr/local/mysql
chmod -R 755 /usr/local/mysql


5. Compile, install and initialize mysql

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


Log last position root@localhost : string, which is the temporary login password of mysql administrator.

If an error is reported, first check whether the linked library file is installed and checked with the command

rpm -qa|grep libaio
 Install the linked library file if there is no result
yum -y install libaio-devel.x86_64
yum -y install numactl

Recompile and record temporary login password

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

6. Edit profile my.cnf , add configuration as follows

vi /etc/my.cnf

Copy the following:

[mysqld]
datadir=/usr/local/mysql/data
port = 3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
symbolic-links=0
max_connections=400
innodb_file_per_table=1
lower_case_table_names=1

7. Start mysql server

/usr/local/mysql/support-files/mysql.server start

The following capacity indicates success

8. Add soft connection and restart mysql service

ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql 
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
service mysql restart


9. Log in to mysql (the password is the temporary password generated in step 5)


10. Set password

set password for root@localhost = password('123456');

Open remote connection

mysql>use mysql;
msyql>update user set user.Host='%' where user.User='root';
mysql>flush privileges;


exit

Set automatic startup
1. Copy the service file to init.d and rename it to mysql

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

2. Give executable permission

chmod +x /etc/init.d/mysqld

3. Add service

chkconfig --add mysqld

4. Show service list

chkconfig --list

The above is MySQL installation under Linux system!!!

MySQL port number: 3306

Connecting windows system to the database in Linux system
click here !!
Just restart iptables!!

Open sqllog test connection


Connection succeeded!

Tags: MySQL Linux RPM yum

Posted on Fri, 19 Jun 2020 01:50:28 -0400 by roflpwnt