[root@sentos /]# cd /home/[root@sentos home]# ls
apache-tomcat-8.5.53.tar.gz jdk-8u161-linux-x64.tar.gz mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
[root@sentos home]# tar -zxvf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz -C /usr/local/mysql/[root@sentos home]# cd /usr/local/mysql/[root@sentos mysql]# ls
mysql-5.7.26-linux-glibc2.12-x86_64
[root@sentos mysql]# mv mysql-5.7.26-linux-glibc2.12-x86_64/ mysql-5.7.27[root@sentos mysql]# ls
mysql-5.7.27
[root@sentos mysql-5.7.27]# groups mysql
groups: mysql: no such user
[root@sentos mysql-5.7.27]# groupadd mysql[root@sentos mysql-5.7.27]# useradd -r -g mysql mysql[root@sentos mysql-5.7.27]# groups mysql
mysql : mysql
[root@sentos mysql-5.7.27]# ls
bin COPYING docs include lib man README share support-files
[root@sentos mysql-5.7.27]# cat /etc/my.cnf[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.# If you need to run mysqld under a different user or group,# customize your systemd unit file for mariadb according to the# instructions in http://fedoraproject.org/wiki/Systemd[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
## include all files from the config directory#!includedir /etc/my.cnf.d
[root@sentos mysql-5.7.27]# mkdir data[root@sentos mysql-5.7.27]# ll
total 36
drwxr-xr-x. 2 root root 4096 Apr 6 11:24 bin
-rw-r--r--. 1 7161 31415 17987 Apr 13 2019 COPYING
drwxr-xr-x. 2 root root 6 Apr 6 11:32 data
drwxr-xr-x. 2 root root 55 Apr 6 11:24 docs
drwxr-xr-x. 3 root root 4096 Apr 6 11:24 include
drwxr-xr-x. 5 root root 230 Apr 6 11:24 lib
drwxr-xr-x. 4 root root 30 Apr 6 11:24 man
-rw-r--r--. 1 7161 31415 2478 Apr 13 2019 README
drwxr-xr-x. 28 root root 4096 Apr 6 11:24 share
drwxr-xr-x. 2 root root 90 Apr 6 11:24 support-files
[root@sentos mysql-5.7.27]# chown -R mysql:mysql ./[root@sentos mysql-5.7.27]# ll
total 36
drwxr-xr-x. 2 mysql mysql 4096 Apr 6 11:24 bin
-rw-r--r--. 1 mysql mysql 17987 Apr 13 2019 COPYING
drwxr-xr-x. 2 mysql mysql 6 Apr 6 11:32 data
drwxr-xr-x. 2 mysql mysql 55 Apr 6 11:24 docs
drwxr-xr-x. 3 mysql mysql 4096 Apr 6 11:24 include
drwxr-xr-x. 5 mysql mysql 230 Apr 6 11:24 lib
drwxr-xr-x. 4 mysql mysql 30 Apr 6 11:24 man
-rw-r--r--. 1 mysql mysql 2478 Apr 13 2019 README
drwxr-xr-x. 28 mysql mysql 4096 Apr 6 11:24 share
drwxr-xr-x. 2 mysql mysql 90 Apr 6 11:24 support-files
[root@sentos mysql-5.7.27]# pwd/usr/local/mysql/mysql-5.7.27
[root@sentos mysql-5.7.27]# cd data/[root@sentos data]# pwd/usr/local/mysql/mysql-5.7.27/data[root@sentos data]# vi /etc/my.cnf[root@sentos data]# cat /etc/my.cnf[mysqld]
basedir=/usr/local/mysql/mysql-5.7.27
datadir=/usr/local/mysql/mysql-5.7.27/data
port=3306
default-character-set=utf8
character-set-server=utf8
skip-name-resolve
default-storage-engine=INNODB
lower_case_table_names=1
max_allowed_packet=100M
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
sql_mode=NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER
# symbolic-links=0# Settings user and group are ignored when systemd is used.# If you need to run mysqld under a different user or group,# customize your systemd unit file for mariadb according to the# instructions in http://fedoraproject.org/wiki/Systemd[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
[root@sentos data]# cd /var/lib/mysql/-bash: cd: /var/lib/mysql/: No such file or directory
[root@sentos data]# cd /var/lib/[root@sentos lib]# ls
alternatives dhclient logrotate NetworkManager polkit-1 rpm-state systemd yum
authconfig games machines os-prober postfix rsyslog tuned
dbus initramfs misc plymouth rpm stateless vmware
[root@sentos lib]# mkdir mysql[root@sentos lib]# ll
total 4
drwxr-xr-x. 2 root root 55 Apr 4 13:10 alternatives
drwx------. 3 root root 18 Apr 4 13:12 authconfig
drwxr-xr-x. 2 root root 6 Mar 14 2019 dbus
drwxr-xr-x. 2 root root 6 Aug 9 2019 dhclient
drwxr-xr-x. 2 root root 6 Apr 11 2018 games
drwxr-xr-x. 2 root root 6 Aug 9 2019 initramfs
drwxr-xr-x. 2 root root 30 Apr 6 10:46 logrotate
drwx------. 2 root root 6 Apr 4 13:10 machines
drwxr-xr-x. 2 root root 37 Apr 4 13:17 misc
drwxr-xr-x. 2 root root 6 Apr 6 11:48 mysql
drwx------. 2 root root 196 Apr 6 10:01 NetworkManager
drwxr-xr-x. 2 root root 6 Nov 6 2016 os-prober
drwxr-xr-x. 2 root root 27 Apr 4 13:10 plymouth
drwxr-x---. 3 root polkitd 28 Apr 4 13:10 polkit-1
drwx------. 2 postfix root 25 Apr 4 13:17 postfix
drwxr-xr-x. 2 root root 4096 Apr 4 18:21 rpm
drwxr-xr-x. 2 root root 6 Apr 11 2018 rpm-state
drwx------. 2 root root 29 Apr 6 11:23 rsyslog
drwxr-xr-x. 4 root root 35 Apr 4 13:10 stateless
drwxr-xr-x. 4 root root 56 Apr 4 13:10 systemd
drwxr-xr-x. 2 root root 6 Aug 8 2019 tuned
drwxr-xr-x. 3 root root 20 Apr 4 13:17 vmware
drwxr-xr-x. 6 root root 80 Apr 4 13:12 yum
[root@sentos lib]# chown mysql mysql[root@sentos lib]# ll
total 4
drwxr-xr-x. 2 root root 55 Apr 4 13:10 alternatives
drwx------. 3 root root 18 Apr 4 13:12 authconfig
drwxr-xr-x. 2 root root 6 Mar 14 2019 dbus
drwxr-xr-x. 2 root root 6 Aug 9 2019 dhclient
drwxr-xr-x. 2 root root 6 Apr 11 2018 games
drwxr-xr-x. 2 root root 6 Aug 9 2019 initramfs
drwxr-xr-x. 2 root root 30 Apr 6 10:46 logrotate
drwx------. 2 root root 6 Apr 4 13:10 machines
drwxr-xr-x. 2 root root 37 Apr 4 13:17 misc
drwxr-xr-x. 2 mysql root 6 Apr 6 11:48 mysql
drwx------. 2 root root 196 Apr 6 10:01 NetworkManager
drwxr-xr-x. 2 root root 6 Nov 6 2016 os-prober
drwxr-xr-x. 2 root root 27 Apr 4 13:10 plymouth
drwxr-x---. 3 root polkitd 28 Apr 4 13:10 polkit-1
drwx------. 2 postfix root 25 Apr 4 13:17 postfix
drwxr-xr-x. 2 root root 4096 Apr 4 18:21 rpm
drwxr-xr-x. 2 root root 6 Apr 11 2018 rpm-state
drwx------. 2 root root 29 Apr 6 11:23 rsyslog
drwxr-xr-x. 4 root root 35 Apr 4 13:10 stateless
drwxr-xr-x. 4 root root 56 Apr 4 13:10 systemd
drwxr-xr-x. 2 root root 6 Aug 8 2019 tuned
drwxr-xr-x. 3 root root 20 Apr 4 13:17 vmware
drwxr-xr-x. 6 root root 80 Apr 4 13:12 yum
[root@sentos lib]# chgrp mysql mysql[root@sentos lib]# ll
total 4
drwxr-xr-x. 2 root root 55 Apr 4 13:10 alternatives
drwx------. 3 root root 18 Apr 4 13:12 authconfig
drwxr-xr-x. 2 root root 6 Mar 14 2019 dbus
drwxr-xr-x. 2 root root 6 Aug 9 2019 dhclient
drwxr-xr-x. 2 root root 6 Apr 11 2018 games
drwxr-xr-x. 2 root root 6 Aug 9 2019 initramfs
drwxr-xr-x. 2 root root 30 Apr 6 10:46 logrotate
drwx------. 2 root root 6 Apr 4 13:10 machines
drwxr-xr-x. 2 root root 37 Apr 4 13:17 misc
drwxr-xr-x. 2 mysql mysql 6 Apr 6 11:48 mysql
drwx------. 2 root root 196 Apr 6 10:01 NetworkManager
drwxr-xr-x. 2 root root 6 Nov 6 2016 os-prober
drwxr-xr-x. 2 root root 27 Apr 4 13:10 plymouth
drwxr-x---. 3 root polkitd 28 Apr 4 13:10 polkit-1
drwx------. 2 postfix root 25 Apr 4 13:17 postfix
drwxr-xr-x. 2 root root 4096 Apr 4 18:21 rpm
drwxr-xr-x. 2 root root 6 Apr 11 2018 rpm-state
drwx------. 2 root root 29 Apr 6 11:23 rsyslog
drwxr-xr-x. 4 root root 35 Apr 4 13:10 stateless
drwxr-xr-x. 4 root root 56 Apr 4 13:10 systemd
drwxr-xr-x. 2 root root 6 Aug 8 2019 tuned
drwxr-xr-x. 3 root root 20 Apr 4 13:17 vmware
drwxr-xr-x. 6 root root 80 Apr 4 13:12 yum
[root@sentos lib]# pwd/var/lib
[root@sentos lib]# cd /usr/local/mysql/mysql-5.7.27/[root@sentos mysql-5.7.27]# ls
bin COPYING data docs include lib man README share support-files
[root@sentos mysql-5.7.27]# cd bin/[root@sentos bin]# ls
innochecksum mysqlcheck mysql_embedded mysql_tzinfo_to_sql
lz4_decompress mysql_client_test_embedded mysqlimport mysql_upgrade
myisamchk mysql_config mysql_install_db mysqlxtest
myisam_ftdump mysql_config_editor mysql_plugin perror
myisamlog mysqld mysqlpump replace
myisampack mysqld-debug mysql_secure_installation resolveip
my_print_defaults mysqld_multi mysqlshow resolve_stack_dump
mysql mysqld_safe mysqlslap zlib_decompress
mysqladmin mysqldump mysql_ssl_rsa_setup
mysqlbinlog mysqldumpslow mysqltest_embedded
[root@sentos bin]# pwd/usr/local/mysql/mysql-5.7.27/bin
[root@sentos bin]# ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/mysql-5.7.27 --datadir=/usr/local/mysql/mysql-5.7.27/data./mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
[root@sentos bin]# apt-get install libaio1-bash: apt-get: command not found
[root@sentos bin]# cat /proc/version
Linux version 3.10.0-1062.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org)(gcc version 4.8.5 20150623 (Red Hat 4.8.5-36)(GCC))#1 SMP Wed Aug 7 18:08:02 UTC 2019[root@sentos bin]# yum install libaio
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: mirrors.huaweicloud.com
* extras: mirrors.nju.edu.cn
* updates: mirrors.nju.edu.cn
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/4): extras/7/x86_64/primary_db | 165 kB 00:00:00
(2/4): base/7/x86_64/group_gz | 165 kB 00:00:00
(3/4): base/7/x86_64/primary_db | 6.0 MB 00:00:01
(4/4): updates/7/x86_64/primary_db | 7.6 MB 00:00:01
Resolving Dependencies
--> Running transaction check
---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================================================
Installing:
libaio x86_64 0.3.109-13.el7 base 24 k
Transaction Summary
=============================================================================================================================================================================================
Install 1 Package
Total download size: 24 k
Installed size: 38 k
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/libaio-0.3.109-13.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for libaio-0.3.109-13.el7.x86_64.rpm is not installed
libaio-0.3.109-13.el7.x86_64.rpm | 24 kB 00:00:00
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-7.1908.0.el7.centos.x86_64 (@anaconda)From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libaio-0.3.109-13.el7.x86_64 1/1
Verifying : libaio-0.3.109-13.el7.x86_64 1/1
Installed:
libaio.x86_64 0:0.3.109-13.el7
Complete![root@sentos bin]# ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/mysql-5.7.27 --datadir=/usr/local/mysql/mysql-5.7.27/data
2020-04-06T04:07:42.373390Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-04-06T04:07:43.254662Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-04-06T04:07:43.428572Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-04-06T04:07:43.492453Z 0 [ERROR] unknown variable 'default-character-set=utf8'
2020-04-06T04:07:43.492473Z 0 [ERROR] Aborting
[root@sentos bin]# cd /etc/init.d/mysql-bash: cd: /etc/init.d/mysql: No such file or directory
[root@sentos bin]# cd /etc/init.d/[root@sentos init.d]# ls
functions netconsole network README
[root@sentos init.d]# mkdir mysql[root@sentos init.d]# cp /usr/local/mysql/mysql-5.7.27/support-files/mysql.server /etc/init.d/mysql[root@sentos init.d]# ls
functions mysql netconsole network README
[root@sentos init.d]# cd mysql/[root@sentos mysql]# ls
mysql.server
[root@sentos mysql]# vi /etc/my.cnf[root@sentos bin]# cat /etc/my.cnf[mysqld]
basedir=/usr/local/mysql/mysql-5.7.27
datadir=/usr/local/mysql/mysql-5.7.27/data
port=3306
# default-character-set=utf8
character-set-server=utf8
skip-name-resolve
default-storage-engine=INNODB
lower_case_table_names=1
max_allowed_packet=100M
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
sql_mode=NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER
# symbolic-links=0# Settings user and group are ignored when systemd is used.# If you need to run mysqld under a different user or group,# customize your systemd unit file for mariadb according to the# instructions in http://fedoraproject.org/wiki/Systemd[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
## include all files from the config directory#!includedir /etc/my.cnf.d
[root@sentos mysql]# cd /usr/local/mysql/mysql-5.7.27/bin/[root@sentos bin]# ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/mysql-5.7.27 --datadir=/usr/local/mysql/mysql-5.7.27/data
2020-04-06T04:18:17.772779Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-04-06T04:18:17.774393Z 0 [ERROR]--initialize specified but the data directory has files in it. Aborting.
2020-04-06T04:18:17.774436Z 0 [ERROR] Aborting
[root@sentos bin]# cd ../[root@sentos mysql-5.7.27]# ls
bin COPYING data docs include lib man README share support-files
[root@sentos mysql-5.7.27]# cd data/[root@sentos data]# ls
ib_buffer_pool ibdata1 ib_logfile0 ib_logfile1
[root@sentos data]# cd ../[root@sentos mysql-5.7.27]# rm -rf data[root@sentos mysql-5.7.27]# mkdir data[root@sentos mysql-5.7.27]# cd data[root@sentos data]# ls[root@sentos data]# cd ../[root@sentos mysql-5.7.27]# cd bin/[root@sentos bin]# ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/mysql-5.7.27 --datadir=/usr/local/mysql/mysql-5.7.27/data
2020-04-06T04:21:59.210615Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-04-06T04:21:59.933935Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-04-06T04:22:00.168215Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-04-06T04:22:00.233448Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 28ed024c-77be-11ea-8346-000c29a701fe.
2020-04-06T04:22:00.234812Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-04-06T04:22:00.257580Z 1 [Note] A temporary password is generated for root@localhost: guGRtuMr%3x=
root@sentos bin]# cd /etc/init.d/mysql-bash: cd: /etc/init.d/mysql: No such file or directory
[root@sentos bin]# cd /etc/init.d/[root@sentos init.d]# ls
functions netconsole network README
[root@sentos init.d]# cp /usr/local/mysql/mysql-5.7.27/support-files/mysql.server /etc/init.d/mysql[root@sentos init.d]# ls
functions mysql netconsole network README
[root@sentos init.d]# ll
total 52
-rw-r--r--. 1 root root 18281 Mar 29 2019 functions
-rwxr-xr-x. 1 root root 10576 Apr 6 12:37 mysql
-rwxr-xr-x. 1 root root 4569 Mar 29 2019 netconsole
-rwxr-xr-x. 1 root root 7923 Mar 29 2019 network
-rw-r--r--. 1 root root 1160 Aug 8 2019 README
[root@sentos init.d]# chkconfig --add mysql[root@sentos init.d]# chkconfig --list
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'.
mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@sentos init.d]# service mysql start
Starting MySQL.2020-04-06T04:42:05.248613Z mysqld_safe error: log-error set to '/var/log/mariadb/mariadb.log', however file don't exists. Create writable for user 'mysql'.
ERROR! The server quit without updating PID file (/usr/local/mysql/mysql-5.7.27/data/sentos.pid).
cd /var/log/mariadb
-bash: cd: /var/log/mariadb: No such file or directory
[root@sentos bin]# cd /var/log/
[root@sentos log]# ls
anaconda boot.log-20200406 dmesg grubby_prune_debug messages spooler vmware-network.1.log vmware-network.4.log vmware-network.log wtmp
audit btmp dmesg.old lastlog rhsm tallylog vmware-network.2.log vmware-network.5.log vmware-vgauthsvc.log.0 yum.log
boot.log cron firewalld maillog secure tuned vmware-network.3.log vmware-network.6.log vmware-vmsvc.log
[root@sentos log]# mkdir mariadb
[root@sentos log]# cd mariadb/
[root@sentos mariadb]# touch mariadb.log
[root@sentos mariadb]# ll
total 0
-rw-r--r-- 1 root root 0 Apr 6 13:02 mariadb.log
[root@sentos mariadb]# cd ../
[root@sentos log]# ll
total 636
drwxr-xr-x. 2 root root 232 Apr 4 13:13 anaconda
drwx------. 2 root root 23 Apr 4 13:17 audit
-rw-------. 1 root root 8282 Apr 6 12:51 boot.log
-rw-------. 1 root root 8156 Apr 6 10:46 boot.log-20200406
-rw-------. 1 root utmp 384 Apr 4 13:17 btmp
-rw-------. 1 root root 4061 Apr 6 13:01 cron
-rw-r--r-- 1 root root 122290 Apr 6 12:51 dmesg
-rw-r--r--. 1 root root 122862 Apr 4 13:17 dmesg.old
-rw-r-----. 1 root root 0 Apr 4 13:17 firewalld
-rw-r--r--. 1 root root 193 Apr 4 13:09 grubby_prune_debug
-rw-r--r--. 1 root root 292000 Apr 6 12:51 lastlog
-rw-------. 1 root root 384 Apr 6 12:51 maillog
drwxr-xr-x 2 root root 25 Apr 6 13:02 mariadb
-rw-------. 1 root root 279806 Apr 6 13:01 messages
drwxr-xr-x. 2 root root 6 Apr 4 13:13 rhsm
-rw-------. 1 root root 6118 Apr 6 12:51 secure
-rw-------. 1 root root 0 Apr 4 13:10 spooler
-rw-------. 1 root root 64000 Apr 6 11:29 tallylog
drwxr-xr-x. 2 root root 23 Apr 4 13:17 tuned
-rw-------. 1 root root 737 Apr 6 12:50 vmware-network.1.log
-rw-------. 1 root root 1094 Apr 6 10:01 vmware-network.2.log
-rw-------. 1 root root 1394 Apr 4 19:31 vmware-network.3.log
-rw-------. 1 root root 1094 Apr 4 15:49 vmware-network.4.log
-rw-------. 1 root root 1394 Apr 4 13:27 vmware-network.5.log
-rw-------. 1 root root 715 Apr 4 13:17 vmware-network.6.log
-rw------- 1 root root 715 Apr 6 12:51 vmware-network.log
-rw-------. 1 root root 3062 Apr 6 12:51 vmware-vgauthsvc.log.0
-rw-r--r--. 1 root root 5510 Apr 6 12:51 vmware-vmsvc.log
-rw-rw-r--. 1 root utmp 5760 Apr 6 12:51 wtmp
-rw-------. 1 root root 56 Apr 6 12:07 yum.log
[root@sentos log]# chown -R mysql:mysql mariadb/
[root@sentos log]# ll
total 636
drwxr-xr-x. 2 root root 232 Apr 4 13:13 anaconda
drwx------. 2 root root 23 Apr 4 13:17 audit
-rw-------. 1 root root 8282 Apr 6 12:51 boot.log
-rw-------. 1 root root 8156 Apr 6 10:46 boot.log-20200406
-rw-------. 1 root utmp 384 Apr 4 13:17 btmp
-rw-------. 1 root root 4061 Apr 6 13:01 cron
-rw-r--r-- 1 root root 122290 Apr 6 12:51 dmesg
-rw-r--r--. 1 root root 122862 Apr 4 13:17 dmesg.old
-rw-r-----. 1 root root 0 Apr 4 13:17 firewalld
-rw-r--r--. 1 root root 193 Apr 4 13:09 grubby_prune_debug
-rw-r--r--. 1 root root 292000 Apr 6 12:51 lastlog
-rw-------. 1 root root 384 Apr 6 12:51 maillog
drwxr-xr-x 2 mysql mysql 25 Apr 6 13:02 mariadb
-rw-------. 1 root root 279806 Apr 6 13:01 messages
drwxr-xr-x. 2 root root 6 Apr 4 13:13 rhsm
-rw-------. 1 root root 6118 Apr 6 12:51 secure
-rw-------. 1 root root 0 Apr 4 13:10 spooler
-rw-------. 1 root root 64000 Apr 6 11:29 tallylog
drwxr-xr-x. 2 root root 23 Apr 4 13:17 tuned
-rw-------. 1 root root 737 Apr 6 12:50 vmware-network.1.log
-rw-------. 1 root root 1094 Apr 6 10:01 vmware-network.2.log
-rw-------. 1 root root 1394 Apr 4 19:31 vmware-network.3.log
-rw-------. 1 root root 1094 Apr 4 15:49 vmware-network.4.log
-rw-------. 1 root root 1394 Apr 4 13:27 vmware-network.5.log
-rw-------. 1 root root 715 Apr 4 13:17 vmware-network.6.log
-rw------- 1 root root 715 Apr 6 12:51 vmware-network.log
-rw-------. 1 root root 3062 Apr 6 12:51 vmware-vgauthsvc.log.0
-rw-r--r--. 1 root root 5510 Apr 6 12:51 vmware-vmsvc.log
-rw-rw-r--. 1 root utmp 5760 Apr 6 12:51 wtmp
-rw-------. 1 root root 56 Apr 6 12:07 yum.log
[root@sentos init.d]# cd /usr/local/mysql/mysql-5.7.27/data
[root@sentos data]# ls
auto.cnf ib_buffer_pool ibdata1 ib_logfile0 ib_logfile1 mysql performance_schema sys
[root@sentos data]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@sentos data]# vi /etc/selinux/config
[root@sentos data]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
# SELINUX=enforcing
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@sentos mariadb]# service mysql start
Starting MySQL.. SUCCESS!
[root@sentos mariadb]# service mysql status
SUCCESS! MySQL running (2883)
[root@sentos mariadb]# ps -ef|grep mysql
root 2656 1 0 13:10 pts/0 00:00:00 /bin/sh /usr/local/mysql/mysql-5.7.27/bin/mysqld_safe --datadir=/usr/local/mysql/mysql-5.7.27/data --pid-file=/usr/local/mysql/mysql-5.7.27/data/sentos.pid
mysql 2883 2656 1 13:10 pts/0 00:00:00 /usr/local/mysql/mysql-5.7.27/bin/mysqld --basedir=/usr/local/mysql/mysql-5.7.27 --datadir=/usr/local/mysql/mysql-5.7.27/data --plugin-dir=/usr/local/mysql/mysql-5.7.27/lib/plugin --user=mysql --log-error=/var/log/mariadb/mariadb.log --pid-file=/usr/local/mysql/mysql-5.7.27/data/sentos.pid --socket=/var/lib/mysql/mysql.sock --port=3306
root 2937 1790 0 13:10 pts/0 00:00:00 grep --color=auto mysql
[root@sentos mysql]# ln -s /var/lib/mysql/mysql.sock /tmp/
[root@sentos bin]# cd /usr/local/mysql/mysql-5.7.27/bin/
[root@sentos bin]# ls
innochecksum myisampack mysqlcheck mysqld-debug mysql_embedded mysql_secure_installation mysql_tzinfo_to_sql resolveip
lz4_decompress my_print_defaults mysql_client_test_embedded mysqld_multi mysqlimport mysqlshow mysql_upgrade resolve_stack_dump
myisamchk mysql mysql_config mysqld_safe mysql_install_db mysqlslap mysqlxtest zlib_decompress
myisam_ftdump mysqladmin mysql_config_editor mysqldump mysql_plugin mysql_ssl_rsa_setup perror
myisamlog mysqlbinlog mysqld mysqldumpslow mysqlpump mysqltest_embedded replace
[root@sentos bin]# ln -s /usr/local/mysql/mysql-5.7.27/bin/mysql /usr/bin/
[root@sentos bin]# service mysql
Usage: mysql {start|stop|restart|reload|force-reload|status} [ MySQL server options ]
[root@sentos bin]# service mysql status
SUCCESS! MySQL running (2883)
[root@sentos bin]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.26
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> alter user 'root'@'localhost' identified by 'root'
-> \G
Query OK, 0 rows affected (0.00 sec)
mysql> select host,user from mysql.user
-> \g
+-----------+---------------+
| host | user |
+-----------+---------------+
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+---------------+
3 rows in set (0.00 sec)
mysql> flush privileges
-> \g
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
[root@sentos bin]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.26 MySQL Community Server (GPL)
mysql> use mysql
Database changed
mysql> update user set host='%' where user = 'root'
-> \g
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges
-> \g
Query OK, 0 rows affected (0.01 sec)
mysql> select host,user from mysql.user
-> \g
+-----------+---------------+| host | user |+-----------+---------------+|%| root || localhost | mysql.session || localhost | mysql.sys |+-----------+---------------+
3 rows in set(0.00 sec)
mysql> exit
Bye
root@sentos bin]# firewall-cmd --list-ports
8080/tcp
[root@sentos bin]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
success
[root@sentos bin]# firewall-cmd --list-ports
8080/tcp
[root@sentos bin]# firewall-cmd --reload
success
[root@sentos bin]# firewall-cmd --list-ports
8080/tcp 3306/tcp
坑总结
# 1,当前环境下时候有安装过,先清除
whereis mysql
find /-name mysql
# 2,解压后查看是否有data文件夹,没有新建
mkdir data# 并编辑my.cnf的数据存放路径cat/etc/my.cnf
# database=新建data的路径# 3,配置my.cnf的socket并开发权限# socket=/var/lib/mysql/mysql.sock
cd /var/lib/ls
mkdir mysql
ll
chown mysql mysql
ll
chgrp mysql mysql
ll
# 4,初始化失败./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/mysql-5.7.27 --datadir=/usr/local/mysql/mysql-5.7.27/data# ./mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory# 缺少 libaio.so.1依赖cat/proc/version # 查看是什么系统 Red Hat 使用 yum
yum install libaio
# 再次初始化# --initialize specified but the data directory has files in it. Aborting.# 这时需要清除 data目录下必须是空文件夹 rm 即可# 再次初始化,直到[Note]出密码即可# 5,启服务
service mysql start# 报错:ERROR! The server quit without updating PID file (/usr/local/mysql/mysql-5.7.27/data/sentos.pid).# my.cnf中:log-error=/var/log/mariadb/mariadb.log
mkdir /var/log/mariadb
cd /var/log/mariadb
touch mariadb # 在该路径下创建该文件即可
chown -R mysql:mysql mariadb/# 6,远程连接访问并开放防火墙
mysql -u root -p
use mysql
update user set host='%' where user = 'root'
flush privileges
select host,user from mysql.user
firewall-cmd --list-ports
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
firewall-cmd --list-ports
Linux mysql5.7版本安装&&坑点总结&&数据库迁移环境准备Centos7.5mysql-5.7.27 linux下的tar.gz包下载链接:https://pan.baidu.com/s/13dE4jZdlg–KVgf7v97GBw提取码:ud25上代码[root@sentos /]# cd /home/[root@sentos ho...