欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

CentOS7 安装mysql8

程序员文章站 2022-03-12 07:57:45
...

进入/usr/local/src

cd /usr/local/src

下载mysql8

wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.11-1.el7.x86_64.rpm-bundle.tar

解压缩

tar xvf mysql-8.0.11-1.el7.x86_64.rpm-bundle.tar

创建文件夹

mkdir mysql-8.0.11-1.el7.x86_64.rpm-bundle

将压缩文件移动到文件夹中

mv mysql-community-* mysql-8.0.11-1.el7.x86_64.rpm-bundle

开始安装

cd mysql-8.0.11-1.el7.x86_64.rpm-bundle

依次序安装

rpm -ivh mysql-community-common-8.0.11-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.11-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-8.0.11-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.11-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.11-1.el7.x86_64.rpm

开启mysql服务

systemctrl start mysqld.service

查看服务状态

systemctrl status mysqld.service

停止服务

systemctrl stop mysqld.service

将MySQL数据文件移动到 /home/data/

mkdir /home/data/
mv /var/lib/mysql/ /home/data/
vi /etc/my.cnf

修改MySQL配置

#将[mysqld]节点下的/var/lib/mysql/相关都修改为/home/data/mysql/
#并在结尾添加
[mysql]
socket=/home/data/mysql/mysql.socket
[client]
socket=/home/data/mysql/mysql.socket
[mysqldump]
socket=/home/data/mysql/mysql.socket
[mysqladmin]
socket=/home/data/mysql/mysql.socket

#lower_case_table_names = 1 #设置表名大小写不敏感
#default-storage-engine=INNODB  #设置Mysql默认数据库存储引擎

重新启动mysql服务

systemctrl start mysqld.service

获取临时登陆密码

grep "password" /var/log/mysqld.log

登陆

mysql -u root -p 临时密码

登陆后第一件事:修改密码

ALTER USER 'root'@'localhost' IDENTIFIED BY '123456#@!123ABC'
创建远程用户
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456#@!123ABC' WITH GRANT OPTION;
FLUSH PRIVILEGES;



相关标签: CentOS7 Mysql8 z