Centos7.3离线(tar方式)安装mysql服务

Posted 大数据从业者

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos7.3离线(tar方式)安装mysql服务相关的知识,希望对你有一定的参考价值。

1. 官网下载压缩包

https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.40-el7-x86_64.tar.gz

2. 卸载系统自带的Mariadb

rpm -qa|grep mariadb
rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64

3.创建mysql用户与用户组

groupadd mysql
useradd -g mysql mysql
passwd mysql

4.解压安装

tar -xvf mysql-5.7.40-el7-x86_64.tar.gz
mv mysql-5.7.40-el7-x86_64 mysql57/
cd mysql57/
mkdir data
chown -R mysql:mysql data

5. 在etc下新建配置文件my.cnf

[mysql]
default-character-set=utf8
[mysqld]
skip-name-resolve
port = 3306
basedir=/usr/local/mysql57
datadir=/usr/local/mysql57/data
max_connections=200
character-set-server=utf8
default-storage-engine=INNODB
lower_case_table_names=1
max_allowed_packet=16M
skip-grant-tables

[mysqld_safe]
error-log=/usr/local/error.log
pid-file=/usr/local/mysql.pid

6. 初始化安装

bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql57/ --datadir=/usr/local/mysql57/data/
cp ./support-files/mysql.server /etc/init.d/mysqld
chown 777 /etc/my.cnf 
chmod +x /etc/init.d/mysqld

7. 重启

 /etc/init.d/mysqld restart

8.开机启动

chkconfig --level 35 mysqld on
chkconfig --list mysqld
chmod +x /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --list mysqld
service mysqld status

9.修改初始密码

cat /root/.mysql_secret 
mysql -uroot -p

  set PASSWORD = PASSWORD(\'123456\');

  Query OK, 0 rows affected (0.01 sec)

10. 添加远程访问权限

GRANT ALL PRIVILEGES ON *.* TO \'root\'@\'%\' IDENTIFIED BY \'youpassword\' WITH GRANT OPTION;
FLUSH PRIVILEGES;

 

以上是关于Centos7.3离线(tar方式)安装mysql服务的主要内容,如果未能解决你的问题,请参考以下文章

centOS7.3 离线安装docker

docker中基于centos7.3搭建tesseract5环境以及制作镜像

docker中基于centos7.3搭建tesseract5环境以及制作镜像

Centos7.3安装Tomcat和MySQL并部署JavaWeb应用

在centos7中离线方式安装mysql5.7

CentOS7.3服务器内网离线部署docker和容器