下载
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.21-linux-glibc2.12-x86_64.tar.xz
上传
文件包移动到/usr/local/
cp mysql-8.0.21-linux-glibc2.12-x86_64.tar.xz /usr/local/
解压
tar xvJf mysql-8.0.21-linux-glibc2.12-x86_64.tar.xz
重命名
mv mysql-8.0.21-linux-glibc2.12-x86_64 mysql-8.0
创建用户
groupadd mysql
useradd -g mysql mysql
授权
chown -R mysql.mysql /usr/local/mysql-8.0
进入 mysql-8.0/
cd mysql-8.0/
创建data
mkdir data
进入bin
cd /bin
初始化
./mysqld --user=mysql --basedir=/usr/local/mysql-8.0 --datadir=/usr/local/mysql-8.0/data/ --initialize
环境设置
sudo yum install libaio
记录密码
编辑my.cnf文件
basedir=/usr/local/mysql-8.0/
datadir=/usr/local/mysql-8.0/data/
socket=/tmp/mysql.sock
character-set-server=utf8
注释mysqld_safe服务
进入mysql8.0路径
cd../
添加mysqld服务到系统 授权及服务
[root@localhost mysql-8.0]# cp -a ./support-files/mysql.server /etc/init.d/mysql
[root@localhost mysql-8.0]# chmod +x /etc/init.d/mysql
[root@localhost mysql-8.0]# chkconfig --add mysql
启动mysql
service mysql start
提示MySQL.2024-05-15T10:33:12.466873Z mysqld_safe error: log-error set to '/var/log/mariadb/mariadb.log', however file don't exists
进入var/log/
cd /var/log/
创建mariadb文件夹 添加文件mariadb.log
[root@localhost log]# mkdir mariadb
[root@localhost log]# cd mariadb/
[root@localhost mariadb]# touch mariadb.log
[root@localhost mariadb]# service mysql start
重启服务
service mysql start
添加服务
ln -s /usr/local/mysql-8.0/bin/mysql /usr/bin
登录mysql
mysql -u -root -p