centOS7.6安装MySQL8

# centOS7.6下安装mysql
# 在/usr/local 下建立mysql文件夹


rpm -qa | grep mariadb               # 查看是否安装mariadb包
rpm
-e XXXXXX --nodeps # 通过该命令卸载mariadb包
cd
/usr/local/mysql # 进入mysql安装目录
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.16-2.el7.x86_64.rpm-bundle.tar # 下载mysql8.0.16

tar -xvf mysql-8.0.16-2.el7.x86_64.rpm-bundle.tar # 解压到当前目录
rpm
-ivh mysql-community-common-8.0.16-2.el7.x86_64.rpm --nodeps --force # 安装common
rpm
-ivh mysql-community-libs-8.0.16-2.el7.x86_64.rpm --nodeps --force # 安装libs
rpm
-ivh mysql-community-client-8.0.16-2.el7.x86_64.rpm --nodeps --force # 安装client
rpm
-ivh mysql-community-server-8.0.16-2.el7.x86_64.rpm --nodeps --force #安装server
rpm
-qa | grep mysql # 查看已经安装的mysql安装包
# 初始化mysql mysqld
--initialize; chown mysql:mysql /var/lib/mysql -R; systemctl start mysqld.service; systemctl enable mysqld; cat /var/log/mysqld.log | grep password # 查看初始密码
mysql
-u root -p # 使用初始密码登录mysql
ALTER USER
'NAME'@'localhost' IDENTIFIED WITH mysql_native_password BY 'PSW'; # 登录后执行该命令,修改密码,重新登录
# 创建远程访问帐号 create user
'NAME'@'%' identified with mysql_native_password by 'PWD'; grant all privileges on *.* to 'NAME'@'%' with grant option; flush privileges;

参考博客

posted @ 2019-05-21 10:27  cooper_wang  阅读(2369)  评论(2编辑  收藏  举报