源码安装mysql8.0.20
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了源码安装mysql8.0.20相关的知识,希望对你有一定的参考价值。
安装依赖库
yum -y install gcc gcc-c++ zlib zlib-devel ncurses ncurses-devel libaio libaio-devel
1、下载mysql8.0.20
wget https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-8.0/mysql-8.0.20-el7-x86_64.tar.gz
2、解压mysql
tar -zxf mysql-8.0.20-el7-x86_64.tar.gz
3.创建安装目录
mkdir -p /usr/local/mysql/data
4、创建mysql进程用户
useradd mysql -s /sbin/nologin -M
5、改变mysql安装目录所有者和属组
chown -R mysql.mysql /usr/local/mysql/
6、复制下载mysql文件到安装目录
cp -r mysql-8.0.20-el7-x86_64/* /usr/local/mysql/
7、切换至msyql安装路径,初始化
1、cd /usr/local/mysql
2、./bin/mysqld --initialize --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
注意:初始化后,最后一行的末尾会有一个随机生成的root密码,请记下!!!!!
8、配置/etc/my.cnf文件如下
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
#socket=/var/lib/mysql/mysql.sock
#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/mysql-error.log
#pid-file=/var/run/mariadb/mariadb.pid
#include all files from the config directory
!includedir /etc/my.cnf.d
9、启动mysql
/usr/local/mysql/support-files/mysql.server start
10、第一次登录mysql会用到初始化随机生成的root密码,并且要求更改密码
登录:/usr/local/mysql/bin/mysql -uroot -p
更改密码:
mysql> alter user ‘root‘@‘localhost‘ identified by ‘123456p‘;
Query OK, 0 rows affected (0.00 sec)
刷新权限:
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
以上是关于源码安装mysql8.0.20的主要内容,如果未能解决你的问题,请参考以下文章