centos8安装mysql8

流星aday
2021-05-26 / 0 评论 / 18 阅读 / 正在检测是否收录...

下载

wget -c https://repo.mysql.com//mysql80-community-release-el8-1.noarch.rpm

安装

rpm -ivh  mysql80-community-release-el8-1.noarch.rpm
dnf -y install mysql-server

修改配置

需先创建目录

mkdir -p /usr/local/mysql/data /usr/local/mysql/tmp

把目录权限给mysql用户

chown -R mysql:mysql /usr/local/mysql/data /usr/local/mysql/tmp

修改配置如下,然后保存。

vim /etc/my.cnf

[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
port=32456
socket=/usr/local/mysql/tmp/mysql.sock
lower_case_table_names=1

[client]
default-character-set=utf8
socket=/usr/local/mysql/tmp/mysql.sock

[mysql]
default-character-set=utf8
socket=/usr/local/mysql/tmp/mysql.sock

启动

首次安装需要初始化,启动服务时间较长

systemctl restart mysqld.service

修改root密码

首次登入无密码,直接回车 。

mysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';

允许root远程访问

use mysql;
update user set host="%" where user="root";
flush privileges;#刷新权限

添加开启自启

systemctl enable mysqld.service
3

评论

博主关闭了所有页面的评论