一、上传mysql压缩包到linux
二、解压配置安装
1.解压
tar -xvf mysql-8.0.25-linux-glibc2.12-x86_64.tar.xz
2.将解压后的文件夹拷贝到/usr/local/并重命名为mysql
mv -f mysql-8.0.25-linux-glibc2.12-x86_64 /usr/local/mysql
3.
建立用户组,并设置mysql文件夹的属主和属组为mysql
[root@wls ~]# groupadd mysql
[root@wls local]# useradd -r -g mysql mysql
#修改mysql文件夹的属主和属组为mysql
[root@wls local]# chown -R mysql:mysql mysql
4.缩小 mysql 用户的权限,防止被恶意利用
[root@wls mysql]# chown -R root .
5.初始化数据库,启动mysql/bin目录下的mysqld(注意保存初始密码)
[root@wls bin]#./mysqld --initialize --user=mysql --lower-case-table-names=1
#注意:--lower-case-table-names=1的作用是设置参数是否区分大小写参数
#如果初始化数据库成功后再在/etc/my.cnf文件添加这句话就会报错(mysql error!The server quit witout updating PID file)
#更详细的看下面的问题记录解答
注意:密码是localhost:后面的部分
6.复制配置文件(my.cnf)到/etc/目录下
[root@wls mysql]# cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
友情提示:不知为什么小编解压后没有找到my-medium.cnf文件,直接在/etc/my.cnf下手动配置的,具体方式点击最下放链接看别人写的吧,此次安装也是参考别人的。
或者手动配置:
[root@mas ~]# vim /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
transaction-isolation = READ-COMMITTED
basedir=/usr/local/mysql
character-set-server=utf8
[client]
port=3306
socket = /var/lib/mysql/mysql.sock
default-character-set=utf8
# Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
#
# include all files from the config directory
"/etc/my.cnf" 27L, 743C
参考资料: