centos 7.9安裝mysql8

一、安裝

1、查看Centos版本

cat /etc/redhat-release

2、卸載之前的mysql和mariadb

rpm -qa|grep mysql
yum -y remove mariadb-libs-5.5.60-1.el7_5.x86_64

3、下載mysql源

wget https://repo.mysql.com//mysql80-community-release-el7-5.noarch.rpm
yum localinstall mysql80-community-release-el7-5.noarch.rpm

4、檢查下源是否包含mysql8.0

yum clean all && yum makecache
yum repolist enabled | grep "mysql.-community."
yum repolist all | grep mysql

5、安裝

yum install mysql-community-server -y

5、啟動并設(shè)置開機自啟

systemctl start mysqld
systemctl enable mysqld
systemctl status mysqld

6、查看版本

mysql --version

7、查看初始密碼并重新設(shè)置

grep 'temporary password' /var/log/mysqld.log
mysql -u root -p //回車后輸入以上查出的密碼
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root-new-password';

二、修改端口

  1. 編輯配置文件
    vim /etc/my.cnf
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

# 加入如下配置
port=3216
  1. 重啟mysql
    systemctl restart mysqld

三、添加用戶

// 添加用戶
CREATE USER 'newuser'@'%' IDENTIFIED BY 'password';

//授權(quán)
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%'
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容