一、上传二进制 mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz包
#/data 是数据盘 自己根据情况定
[root@VM_0_10_centos data]# pwd
/data
tar xf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.26-linux-glibc2.12-x86_64 mysql
#做软连接
ln -s /data/mysql /usr/local/mysql
cd /data/mysql
mkdir data
groupadd mysql
useradd -M -g mysql -s /sbin/nologin -d /usr/local/mysql mysql
chown -R mysql.mysql /usr/local/mysql/
rpm -qa | grep maria*
yum -y remove mari*
#安装库
yum install -y libnuma*
二、mysql 初始化、启动、修改密码、开机自启动
[mysqld]
port=3306
character-set-server=utf8
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
#innodb_buffer_pool_size=8M
max_connections=1000
slow_query_log = 1
slow_query_log_file=/usr/local/mysql/log/mysql_slow_query.log
long_query_time = 5
max_connections=1000
socket=/var/lib/mysql/mysql.sock
[mysqld_safe]
log-error=/usr/local/mysql/data/error.log
pid-file=/usr/local/mysql/data/mysql.pid
tmpdir=/usr/local/mysql/tmp
[client]
default-character-set=utf8
socket=/var/lib/mysql/mysql.sock
[mysql]
default-character-set=utf8
# 初始化
./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
# 配置启动文件
cp ./support-files/mysql.server /etc/init.d/mysqld
vim /etc/init.d/mysqld
#basedir=/usr/local/mysql
#datadir=/usr/local/mysql/data
#mysqld_pid_file_path=/usr/local/mysql/data/mysql.pid
#启动数据库
service mysqld start
#修改密码
./bin/mysql -u root -p
SET PASSWORD FOR 'root'@localhost=PASSWORD('Your Password');
#添加环境变量
vim /etc/profile
export MYSQL_HOME=/usr/local/mysql
export PATH=$MYSQL_HOME/bin:$PATH
#环境变量生效
source /etc/profile
#开机自启动
[root@VM_0_14_centos mysql]# chmod +x /etc/rc.d/init.d/mysqld
[root@VM_0_14_centos mysql]# chkconfig --add mysqld
[root@VM_0_14_centos mysql]# chkconfig --list mysqld
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]'.
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
# 如果是centos7 话可以检查一下
systemctl start mysqld
systemctl stop mysqld
systemctl status mysqld