1.查看是否有安装mariadb
yum list installed | grep mariadbyum remove mariadb
2.上传解压文件
tar -zxvf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gzmv mysql-5.7.28-linux-glibc2.12-x86_64 /usr/local/mysql
3.创建数据目录
mkdir -p /data/mysql/data
4.添加mysql用户及用户组
groupadd mysqluseradd -r -s /sbin/nologin -g mysql mysql -d /usr/local/mysql
5.更改所属的组和用户
cd /usr/local/mysqlchown -R mysql .chgrp -R mysql .chown -R mysql /data/mysql
6.安装初始化
百度云安装问题记录
error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory# yum 安装的libnuma.so.1,但安装时默认安装的是32的,但db2需要的是64位的yum remove libnuma.so.1yum -y install numactl.x86_64
cd /usr/local/mysqlbin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data2021-03-30T10:18:25.212584Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2021-03-30T10:18:26.237192Z 0 [Warning] InnoDB: New log files created, LSN=457902021-03-30T10:18:26.356956Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.2021-03-30T10:18:26.459079Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 43fe917f-9141-11eb-a515-00163e3019ff.2021-03-30T10:18:26.460035Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.2021-03-30T10:18:27.546222Z 0 [Warning] CA certificate ca.pem is self signed.2021-03-30T10:18:28.087215Z 1 [Note] A temporary password is generated for root@localhost: vi!g5T1lK(t2
7.修改 mysql 配置文件
vi /usr/local/mysql/support-files/mysql.serverbasedir=/usr/local/mysqldatadir=/data/mysql/datacp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
8.修改 my.cnf 文件
vi /etc/my.cnf[mysqld]port = 3306basedir=/usr/local/mysqldatadir=/data/mysql/datamax_connections=200default-storage-engine=INNODBlower_case_table_names=1max_allowed_packet=64Msql-mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
9.启动并登录mysql
/etc/init.d/mysqld start[root@tcloud mysql]# /etc/init.d/mysqld startStarting MySQL.Logging to '/data/mysql/data/tcloud.err'... ERROR! The server quit without updating PID file (/data/mysql/data/tcloud.pid).# 查看日志进行文件处理/usr/local/mysql/bin/mysql -u root -p'r3qz>ar.0=gK'
10.修改root用户密码
set password=password('tcloud@2021');# 授权否则 Navicat 无法连接grant all privileges on *.* to root@'%' identified by 'tcloud@2021';flush privileges;quit;
11.将 MySQL 加入 Service 系统服务
# 配置环境变量vim /etc/profileexport MYSQL_HOME="/usr/local/mysql"export PATH="$PATH:$MYSQL_HOME/bin". /etc/profile# 启动chkconfig --add mysqldchkconfig mysqld onservice mysqld restartservice mysqld status
12.其他配置
# 查看端口号netstat -lntup|grep 3306# mysql后台启动bin/mysqld_safe --defaults-file=/data/mysql-5.7.28/my.cnf --user=root &# 配置文件不生效(权限过大)
