centos 7.5 install mysql5.7.17

Prepare environment and installation package

linux :centos 7.5

mysql binary compressed package

Compressed package connection: https://downloads.mysql.com/archives/community/

1、 Confirm whether maridb is installed locally, if so, uninstall it first

rpm -qa | grep Mariabd

yum remove -nodeps -y maridb-xxx

2、 After the local environment is cleaned up, create related directories

(Official default directory: /usr/local/mysql)

mysql storage data directory: mkdir dbdata

Application data storage directory: mkdir appdata

Binlog log storage directory: mkdir dbbinlog

3、 Add mysql user/user group

useradd mysql

groupadd mysql

Assign users and user groups to the above three directories

4、 Unzip the mysql5.7 installation package

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

After decompression as follows, then create a soft link to this directory for subsequent use of this file

5、 Set environment variables

vim /etc/profile

export PATH=/data/dbdata/mysql/bin:$PATH

source /etc/profile

mysql -V under verification

6、 Initialize mysql

mysqld --initialize-insecure --user=mysql --basedir=/data/appdata/mysql --datadir=/data/dbdata/

6.1、 Initialization statement expansion

mysqld --initialize-insecure: Will not generate a password, log in directly with an empty password, it is recommended to initialize without a password

mysqld --initialize: This parameter will randomly generate a password, which needs to be checked in the log (it should be in the mysqld.err log)

I got an error after executing here, as shown in the figure

This is because my path is wrong

Successfully initialized after modification

Note: The most common errors here are probably as follows

6.1、

mysqld: error while loading shared libraries: libaio.so.q:

cannot open shared object file: no such file or directory

Solution: yum install -y libaio-devel

6.2、

2020- 07- 21 T04:53:03.990092Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2020- 07- 21 T04:53:03.991746Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.

2020- 07- 21 T04:53:03.991774Z 0 [ERROR] Aborting

Solution: clean up the datadir directory

rm -rf /data/dbdata/*

7、 Configure my.cnf configuration file

[ mysqld]

user=mysql

basedir=/data/appdata/mysql

datadir=/data/dbdata

server_id=101

port=3306

socket=/tmp/mysql.sock

[ mysql]

socket=/tmp/mysql.sock

8、 Start the mysqld service

service mysqld start or systemctl start mysql.service

Start error, as follows

/data/appdata/mysql/bin/mysqld_safe: line 586: /usr/local/mysql/data/mysqld_safe.pid: No such file or directory

awk: (FILENAME=- FNR=1) warning: error writing standard output (Broken pipe)

2020- 07- 21 T07:02:57.447677Z mysqld_safe Logging to '/usr/local/mysql/data/VM-48-17-centos.err'.

Logging to '/usr/local/mysql/data/VM-48-17-centos.err'.

2020- 07- 21 T07:02:57.451028Z mysqld_safe The file /usr/local/mysql/bin/mysqld

does not exist or is not executable. Please cd to the mysql installation

directory and restart this script from there as follows:

. /bin/mysqld_safe&

See http://dev.mysql.com/doc/mysql/en/mysqld-safe.html for more information

Solution:

Because the mysqld_safe startup script reads another startup script mysqld from the /usr/local/mysql directory by default, because my installation directory is

/data/appdata/msyql, so the error is reported as above

Here you can do the soft connection of this path according to the error report to solve

mkdir -p /usr/local/mysql/bin

ln -s /data/appdata/mysql/bin/mysqld /usr/local/mysql/bin/mysqld

Then start the service again

Extension: If it is a mysql 5.6 installation package, there is no difference in the installation steps, but the execution statement is different during initialization

/data/appdata/mysql/scripts/mysql_instll_db --user=mysql --basedir=/data/appdata/mysql --datadir=/data/dbdata/

Recommended Posts

CentOS7.2 install Mysql5.7.13
CentOS7 install MySQL
CentOS7 install mysql
CentOS 7 install MySQL 5.6
CentOS8 install MySQL8.0
CentOS7 install mysql8
CentOS7 install MySQL8
centos 7.5 install mysql5.7.17
CentOS6.5 offline install MySQL5.6.26
Install MySQL5.7 in centos7
Install mysql5.7 under CentOS7
CentOS 7.2 Yum install MySQL 5.6
Centos7 install Mysql8 tutorial
Centos manually install mysql8
Install mysql under Centos 7
Centos7 install Mysql database
Install mysql5.1 under CentOS6.5
Install mysql online on centos
Install MySQL 8.0.16 on Linux Centos
Install MySQL under Linux (CentOS 7)
Centos6 install mysql 5.7.x series
CentOS8 install MySQL8 (pro test)
Centos6 install Python2.7.13
How to install MySQL on CentOS 8
CentOS7 yum install and start mysql
Centos7.3 install nginx
CentOS Yum compile and install MySQL 5.6
CentOS install Redmine
Centos7 install Python 3.6.
Centos7 install protobuf
CentOS 7 install Docker
CentOS 7 install Nginx, PHP, MySQL packages
CentOS 7.4 install Zabbix 3.4
CentOS7 install Docker
Centos6.5 install Tomcat
CentOS install Python 3.6
Vmware install CentOS6
centos7 install docker-ce 18.01.0
CentOS 7.2 install MariaDB
CentOS 7 install Hadoop 3.0.0
Install MySql with Docker in CentOS7
Centos7 install Python2.7
Centos 7.6 install seleniu
CentOS 7.3 install Zabbix3
Centos7 install LAMP+PHPmyadmin
Install MySQL on Linux CentOS7 (Windows)
CentOS install openjdk 1.8
CENTOS6.5 install CDH5.12.1 (1)
CentOS install PHP
CentOS7 yum install and start mysql
CentOS6 install mist.io
Centos7 install Docker
Centos yum install mysql5.6 or above
centOs install rabbitMQ
Centos7 install Nginx
CentOS6.5 install CDH5.13
Centos7 install docker18
Centos install Python3
centos7 install docker
CentOS install jdk
Centos6.3 install KVM