当前位置:网站首页>MySQL Linux Installation mysql-5.7.24

MySQL Linux Installation mysql-5.7.24

2022-06-12 05:09:00 vihem

Related to the environment

Linux: CentOS 7 64 position
Jdk: 1.8.0_231
MySQL: 5.7.24

Check before installation

Insist on whether it is installed mysql/mariadb

rpm -e mysql
rpm -qa | grep mysql
rpm -qa | grep mariadb
whereis mysql #  see mysql Catalog 

return error: package mysql is not installed That is no mysql;
If you have any , Delete it :

rpm -e --nodeps  The name of the document found 
rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64
rm -rf  Directory name 
yum remove mysql-libs #yum Delete by , If you use yum Installation mode 

install mysql May be with MariaDB There are conflicts , So it needs to be deleted .

 

download 、 Upload 、 Unzip the relevant files

Download from the official website ( Or download according to your own needs )
mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
 Insert picture description here

Upload to Linux, decompression , Move to /usr/local/:

rz -E
tar zxvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.24-linux-glibc2.12-x86_64 /usr/local/mysql

 Insert picture description here

 

To configure

  1. establish data

    mkdir /usr/local/mysql/data
    
  2. Create user groups and users , modify mysql Authority

    groupadd mysql
    useradd mysql -g mysql
    chown -R mysql:mysql mysql/
    

     Insert picture description here

  3. initialization MySQL, Record the returned password

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

     Insert picture description here
    password :h4jgn7s&aKz!

  4. Create soft link

    Make global use of mysql command :

    ln -s /usr/local/mysql/bin/mysql /usr/bin
    

    Make available service Command to start-up

    ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
    service mysql restart
    
  5. Sign in MySQL

    mysql -u root -p
    

     Insert picture description here

  6. After logging in , Change Password , Open remote permissions :

    alter user 'root'@'localhost' identified by '123456';
    use mysql;
    update user set user.Host='%' where user.User='root';
    grant all privileges on *.* to root@'%' identified by '123456';
    flush privileges;
    quit
    
  7. Modify the configuration file /etc/my.cnf

    vim /etc/my.cnf
    
    [mysqld]
    character_set_server=utf8
    basedir=/usr/local/mysql
    datadir=/usr/local/mysql/data
    port=3306
    socket=/tmp/mysql.sock
    sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
    symbolic-links=0
    max_connections=600
    innodb_file_per_table=1
    lower_case_table_names=1
     
    ####################  other   Can not add  ####################
    #  China standard time ,  Will be output 08:00
    # default-time_zone = '+8:00'
    # default-storage-engine=INNODB
    # collation-server=utf8_general_ci
    #  Query settings 
    #  Open slow query log ( Or set 1)
    # slow_query_log=1
    # #  Specify the path to save the log file , If not specified, it will be in the database file directory by default    Note that files must be created manually   And authority 
    # slow_query_log_file=/var/log/mysql_slow.log
    # #  Specify how many seconds to slow a query   subtle 
    # long_query_time=5
    #  Record queries that do not use indexes 
    # log_queries_not_using_indexes=on
    #  It shows that it is allowed to record every minute slow log Not indexed sql Number of statements 
    # log_throttle_queries_not_using_indexes=10
    #  How to store logs 
    # log_output=FILE
    # sql_mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
    

    restart mysql, Sign in , Use the following command to check lower_case_table_names Is it 1, by 1 Indicates that the configuration is modified successfully

    show variables like "%case%";
    
  8. Set power on self start

    chkconfig mysql on
    
  9. Turn off firewall ( Or expose the port )

    systemctl stop firewalld.service
    

    installation is complete .
     

start-up MySQL

/usr/local/mysql/support-files/mysql.server start
service mysql start
service mysql restart
service mysql stop
ps -ef | grep mysql

Use navicat Successful connection :
 Insert picture description here


If there is something wrong , Please understand and criticize , thank you ~
Reprint please indicate :
https://blog.csdn.net/vihem/article/details/123171414

原网站

版权声明
本文为[vihem]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203010621316662.html