MySQL安装

准备环境

Centos8  MySQL8

前置环境

# 提供文件下载/上传
yum install  lrzsz -y
                
yum install libaio
yum install -y ncurses-compat-libs

下载安装

MySQL8官网下载地址

cd /usr/local/

# 将从官网下载的压缩包上传到/usr/local/目录下
rz 
tar -xvf mysql-8.0.25-linux-glibc2.12-x86_64.tar.xz 
mv mysql-8.0.25-linux-glibc2.12-x86_64 mysql

groupadd mysql useradd
-r -g mysql -s /bin/false mysql cd mysql
mkdir mysql-files chown mysql:mysql mysql-files chmod 750 mysql-files # 注意此处会自动生成root用户的临时密码 bin/mysqld --initialize --user=mysql bin/mysql_ssl_rsa_setup # 启动MySQL bin/mysqld_safe --user=mysql &

配置

环境变量

vim /etc/profile

# 在文件头插入
export PATH=${PATH}:/usr/local/mysql/bin

# 重新加载
source /etc/profile

修改密码

mysql -uroot -p xxxxxx
alter user 'root'@'localhost' identified by 'root';

修改可访问IP

use mysql;
update user set host = '%' where user = 'root';
flush privileges;

身份验证插件修改

alter user 'root'@'%' identified with mysql_native_password by 'root';

自启动

配置文件添加到自启动目录并授权

cd /usr/local/mysql/support-files/
cp mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql

修改自启动文件配置

vim /etc/init.d/mysql
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data

开启自启动

chkconfig --add mysql
chkconfig --level 345 mysql on

 开放端口

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

 

posted @ 2021-05-16 18:23  五毒不侵滴bug  阅读(56)  评论(0)    收藏  举报