centos7安装mysql8特变慢_Centos7安装MySQL8

本文详细介绍了如何在CentOS7上安装MySQL8.0,包括下载二进制包,设置基础环境,初始化数据库,创建配置文件,启动MySQL服务以及修改初始密码的步骤。
摘要由CSDN通过智能技术生成

一、下载

注意下载二进制包,解压可以直接使用的,这里安装最新版本8.0.17

wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz

二、基础环境设置

useradd -r mysql

mkdir -pv /soft/

mkdir -pv /data/mysqldata/node1/log

tar -xf mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz

mv mysql-8.0.17-linux-glibc2.12-x86_64 /soft/mysql

touch /data/mysqldata/node1/log/mysql.err

chown -R mysql.mysql /soft/mysql

chown -R mysql.mysql /data/mysqldata

三、初始化

$/soft/mysql/bin/mysqld -I --user=mysql --basedir=/soft/mysql --datadir=/data/mysqldata/node1

2019-09-29T08:52:14.894707Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.

2019-09-29T08:52:14.894931Z 0 [System] [MY-013169] [Server] /soft/mysql/bin/mysqld (mysqld 8.0.17) initializing of server in progress as process 3278

2019-09-29T08:52:18.243191Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: geXg5X90bE?W -mysql8默认密码

2019-09-29T08:52:19.909851Z 0 [System] [MY-013170] [Server] /soft/mysql/bin/mysqld (mysqld 8.0.17) initializing of server has completed

四、配置文件

1.创建配置文件

vim my.cnf

[client]

socket=/tmp/mysql-node1.sock

[mysql]

log-error=/data/mysqldata/node1/log/mysql.err

[mysqld]

basedir=/soft/mysql

datadir=/data/mysqldata/node1

socket=/tmp/mysql-node1.sock

port=33066

user=mysql

log_timestamps=SYSTEM

default_authentication_plugin= mysql_native_password

log-error=/data/mysqldata/node1/log/mysql.err

[mysqld_safe]

log-error=/data/mysqldata/node1/log/mysql.err

pid-file=/tmp/mysqld-node1.pid

socket=/tmp/mysql-node1.sock

[mysql.server]

socket=/tmp/mysql-node1.sock

[mysqladmin]

socket=/tmp/mysql-node1.sock

2.移动到对应数据库项目

mv my.cnf /data/mysqldata/node1/

3.设置环境变量

vim /etc/profile

export PATH=$PATH:/soft/mysql/bin

source /etc/profile

五、启动

1.手动启动

/soft/mysql/bin/mysqld_safe --defaults-file=/data/mysqldata/node1/my.cnf >/dev/null &

2.放入脚本

cp /soft/mysql/support-files/mysql.server /etc/init.d/mysql.server

chkconfig --add /etc/init.d/mysql.server

将mysql.server脚本里面的basedir datadir路径修改一下就可以了

systemctl start mysql.server

六、修改密码

第一次登陆要求修改密码才能操作

mysql -uroot -S /tmp/mysql-node1.sock -p pwd:geXg5X90bE?W

mysql> show databases;

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

修改密码

mysql> alter user 'root'@'localhost' identified by 'FwaX63cSCWq';

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值