Install MySQL and related environment configuration under Linux

Preface

MySQL is the most popular relational database management system. In terms of web applications, MySQL is one of the best RDBMS (Relational Database Management System) application software

Official website  https://www.mysql.com/ 

 

installation steps

1. Download the source code

   https://downloads.mysql.com/archives/community/

  Method 1: Link: https://pan.baidu.com/s/1uZIIEhpjAPMZCJ8Ux2Df7A  Password: p6wq

  Way two:

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

2. Unzip the source code

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

3. Rename

mv mysql-5.7.24-linux-glibc2.12-x86_64 mysql

4. Create the data directory

mkdir /usr/local/mysql/data

5. Change user groups and users and permissions

groupadd mysql
useradd -r -g mysql mysql
chown -R mysql:mysql /usr/local/mysql
chmod -R 755 /usr/local/mysql

6. Install dependent libraries

yum -y install numactl

7. Compile and remember the initialization password

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

8. Edit the configuration file my.cnf

vi /etc/my.cnf

  Press i in English input state to enter insert mode, add the following configuration 


[mysqld]
innodb_buffer_pool_size = 32M

datadir=/usr/local/mysql/data
port=3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
symbolic-links=0
max_connections=600
innodb_file_per_table=1
lower_case_table_names=1
character_set_server=utf8


character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'


[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4

  Press esc and enter  : wq to  save and exit
  lower_case_table_names : whether it is case sensitive, 1 means that the table name is lowercase when storing, and is not case sensitive during operation; 0 means case sensitive; it cannot be dynamically set, after modification, it must be restarted to take effect:
  character_set_server : Set the database default character set, if not set, the default is latin1
  innodb_file_per_table : Whether to store the data of each table separately, 1 means separate storage; 0 means to close the independent table space, you can check the file structure difference by viewing the data directory 

9. Set up soft connection

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

10. Add PATH

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

11. Start

service mysql start

11. Set password

mysql -h 127.0.0.1  -u root -p
set password for root@localhost = password('newpass');
use mysql;
update user set user.Host='%' where user.User='root';
flush privileges;

  Note: Prompt to enter the password, fill in the initial password to start recording

12. Set boot up

chmod +x /etc/init.d/mysqld
chkconfig --add mysqld

12. Start/stop/restart

service mysql stop
service mysql restart

13. Connect

Guess you like

Origin blog.csdn.net/javanbme/article/details/111825296