centos7mysql8.0解压缩版安装流程

2021/6/16 19:24:29

本文主要是介绍centos7mysql8.0解压缩版安装流程,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

下载mysql:

mysql-8.0.25-linux-glibc2.12-x86_64.tar.xz

下载地址:
https://dev.mysql.com/downloads/mysql/

解压到/usr/local路径:

tar -xvf mysql-8.0.25-linux-glibc2.12-x86_64.tar.xz -C /usr/local/

切换到/usr/local目录,修改mysql根目录名称:

mv mysql-8.0.25-linux-glibc2.12-x86_64/ mysql

创建mysql用户:

groupadd mysql
useradd -g mysql mysql

切换到mysql根目录下 cd /usr/local/mysql,并创建data文件夹:

mkdir data

授权mysql用户文件夹访问权限:

chown -R mysql:mysql /usr/local/mysql

切换到/usr/local/mysql/bin目录下,初始化mysql:

./mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize

记住初始化生成的密码:例:O,3d<-eG+iDv

编辑mysql配置文件 vim /etc/my.cnf,并修改对应datadir、socket、log-error、pid-file为如下内容:

[mysqld]
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
max_connections=1000

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

把mysqld服务拷贝到系统:

cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

授权并设置开启自启动:

chmod +x /etc/init.d/mysql 
chkconfig --add mysql

启动mysql服务

service mysql start

设置mysql软链接:

ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql

查看临时密码

grep "A temporary password" /var/log/mysqld.log

登录mysql:

mysql -uroot -p

输入临时密码:例:O,3d<-eG+iDv

修改密码

alter user 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'O,3d<-eG+iDv';

使用mysql语句

use mysql;

设置用户host

update user set host='%' where user ='root';

开放远程连接

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;

刷新权限

flush privileges;

退出

exit

查看防火墙状态

firewall-cmd --state

查看防火墙开放端口

firewall-cmd --zone=public --list-ports

开放3306端口

firewall-cmd --zone=public --add-port=3306/tcp --permanent

配置防火墙端口生效

firewall-cmd --reload


这篇关于centos7mysql8.0解压缩版安装流程的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程