将安装包上传到服务器上
下载地址https://downloads.mysql.com/archives/community/ 上传到服务器的usr/local目录
cd /usr/local
解压
tar -zxvf 你的压缩包的名字
解压完成之后进行重命名
mv 解压缩后的目录名 mysql
创建data文件夹
mkdir /usr/local/mysql/data
创建 mysql 用户组和 mysql 用户
groupadd mysql
useradd -g mysql mysql
改变 mysql 目录权限
chown -R mysql.mysql /usr/local/mysql/
初始化数据库
创建mysql_install_db安装文件
cd /usr/local/mysql
mkdir mysql_install_db
chmod 777 ./mysql_install_db
初始化
bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
这是会产生一个随机密码
[Server] A temporary password is generated for root@localhost: 密码
请将这密码保存
安装 libnuma
yum install libnuma
yum -y install numactl
yum install libaio1 libaio-dev
mysql配置
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
修改my.cnf文件
vim /etc/my.cnf
将以下内容覆盖原来的内容
[mysqld]
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
socket = /usr/local/mysql/mysql.sock
character-set-server=utf8
port = 3306
[client]
socket = /usr/local/mysql/mysql.sock
default-character-set=utf8
[mysqld_safe]
log-error=/usr/local/mysql/data/slave.err
建立MySQL服务
cp -a ./support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --list mysqld
配置环境变量
vi /etc/profile
在文件最下方加入
export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib
export PATH
之后执行
source /etc/profile
启动
/etc/init.d/mysqld start
修改密码
use mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY "你的密码";
FLUSH privileges;
设置远程登陆
use mysql
update user set host='%' where user='root' limit 1;
flush privileges;
GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION;
设置开机启动
systemctl enable mysqld
systemctl daemon-reload
本教程参考多篇博客,来之不易,是博主踩坑了近一周总结出来的步骤,如果按照这个步骤,可以说完全没有问题,点个赞支持一下呗
|