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