码迷,mamicode.com
首页 > 数据库 > 详细

源码安装mysql8.0.20

时间:2020-11-23 12:24:47      阅读:10      评论:0      收藏:0      [点我收藏+]

标签:log   lin   用户   yum   初始化   down   ted   安装路径   ide   

安装依赖库

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

标签:log   lin   用户   yum   初始化   down   ted   安装路径   ide   

原文地址:https://blog.51cto.com/6461704/2551958

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!