centos7安装mysql8.0

mysql官网地址:MySQL :: Download MySQL Community Server (Archived Versions)

centos7安装mysql8.0_第1张图片

1.上传到 /usr/local 路径下

2.解压

	tar -xvf mysql-8.0.31-linux-glibc2.12-x86_64.tar.xz

3.重命名

mv mysql-8.0.31-linux-glibc2.12-x86_64.tar.xz mysql

4.创建mysql用户组和用户并修改权限

groupadd mysql
useradd -r -g mysql mysql

5.创建目录并赋予权限

mkdir -p  /data/mysql              #创建目录
chown mysql:mysql -R /data/mysql   #赋予权限

6.配置my.cnf文件

vim /etc/my.cnf

[mysqld]
bind-address=0.0.0.0
port=3306
user=mysql
basedir=/usr/local/mysql
datadir=/data/mysql
socket=/tmp/mysql.sock
log-error=/data/mysql/mysql.err
pid-file=/data/mysql/mysql.pid
#character config
character_set_server=utf8mb4
symbolic-links=0
explicit_defaults_for_timestamp=true

7.初始化

cd /usr/local/mysql/bin/

./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --user=mysql --initialize

8.查看密码

cat /data/mysql/mysql.err

9.将mysql.server放置到/etc/init.d/mysql中

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

10.启动

service mysql start

11.修改默认密码

./mysql -u root -p   #bin目录下

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
flush privileges;

12.配置远程连接

use mysql;
update user set host='%' where user='root';
flush privileges;

13.查看安装路径和安装环境是否正常

whereis mysql;
whereis mysqldump;

***如果少了需要手动配置

vi /etc/profile

在最后一行添加
export PATH=$PATH:/usr/local/mysql/bin

source /etc/profile

你可能感兴趣的:(mysql,mysql)