rpm -qa | grep -i mariadb
rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
cat /etc/group | grep -i mysql
cat /etc/passwd | grep -i mysql
下载连接如下:
https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.38-el7-x86_64.tar
或
https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.38-el7-x86_64.tar.gz
或
https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.38-1.el7.x86_64.rpm-bundle.tar
注:具体用哪个包自己选择;
tar -xvf mysql-5.7.38-el7-x86_64.tar
tar -xvf mysql-5.7.38-el7-x86_64.tar.gz
cd /usr/local
ln -s /data/packages/mysql-5.7.38-el7-x86_64 mysql
useradd mysql
mkdir -p /data/mysql/{data,logs,tmp}
注:具体目录用途,视个人情况而定:
-data:mysql数据目录
-longs:mysql日志目录
-tmp:mysql临时目录
chown -R mysql:mysql /data/packages/mysql-5.7.38-el7-x86_64
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /data/mysql/
vi /etc/my.cnf
cat /etc/my.cnf
[client]
port = 3306
socket = /data/mysql/tmp/mysql.sock ##自定义socket文件路径
[mysqld]
user = mysql
basedir = /usr/local/mysql ##定义mysql安装路径
datadir = /data/mysql/data ##定义mysql数据目录
port = 3306
socket = /data/mysql/tmp/mysql.sock
pid-file = /data/mysql/tmp/mysqld.pid
tmpdir = /data/mysql/tmp ##定义mysql的临时文件路径
skip_name_resolve = 1
symbolic-links=0
max_connections = 2000
group_concat_max_len = 1024000
sql_mode = NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
lower_case_table_names = 1
log_timestamps=SYSTEM
character-set-server = utf8
interactive_timeout = 1800
wait_timeout = 1800
max_allowed_packet = 32M
binlog_cache_size = 4M
sort_buffer_size = 2M
read_buffer_size = 4M
join_buffer_size = 4M
tmp_table_size = 96M
max_heap_table_size = 96M
max_length_for_sort_data = 8096
#logs
server-id = 1003306
log-error = /data/mysql/logs/error.log ##定义error.log的路径
slow_query_log = 1
slow_query_log_file = /data/mysql/logs/slow.log ##定义slow.log的路径
long_query_time = 3
log-bin = /data/mysql/logs/binlog ##定义binlog的路径
binlog_format = row
expire_logs_days = 15
log_bin_trust_function_creators = 1
relay-log = /data/mysql/logs/relay-bin
relay-log-recovery = 1
relay_log_purge = 1
#innodb
innodb_file_per_table = 1
innodb_log_buffer_size = 16M
innodb_log_file_size = 256M
innodb_log_files_in_group = 2
innodb_io_capacity = 2000
innodb_io_capacity_max = 4000
innodb_flush_neighbors = 0
innodb_flush_method = O_DIRECT
innodb_autoinc_lock_mode = 2
innodb_read_io_threads = 8
innodb_write_io_threads = 8
innodb_buffer_pool_size = 2G
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
vim /etc/init.d/mysql
修改如下行:
46 basedir=/usr/local/mysql ##定义mysql安装目录
47 datadir=/data/mysql/data ##定义mysql数据目录
chmod 755 /etc/profile
echo "PATH=$PATH:/usr/local/mysql/bin " >> /etc/profile
source /etc/profile
chmod 644 /etc/profile
yum -y install libaio*
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data
/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf
more /data/mysql/logs/error.log | grep password
service mysql start
chkconfig --add mysql
chkconfig --list
mysql_secure_installation
由此可见,MySQL-5.7.38已经安装完成,且可以正常登录并进行使用;