# 通過命令檢視mariadb的安裝包
[root@master ~]
# rpm -qa | grep mariadb
# 通過命令清除mariabd的所有安裝包
[root@master ~]
# rpm -e mariadb-libs-5.5.56-2.el7.x86_64 --nodeps
# 通過命令再次檢視mariadb的安裝包是否已清理
[root@master ~]
# rpm -qa | grep mariadb
# 解壓mysql包
[root@master local]
# tar -xvf mysql-8.0.16-2.el7.x86_64.rpm-bundle.tar
# 安裝common
[root@master local]
# rpm -ivh mysql-community-common-8.0.16-2.el7.x86_64.rpm --nodeps --force
# 安裝libs
[root@master local]
# rpm -ivh mysql-community-libs-8.0.16-2.el7.x86_64.rpm --nodeps --force
# 安裝client
[root@master local]
# rpm -ivh mysql-community-client-8.0.16-2.el7.x86_64.rpm --nodeps --force
# 安裝server
[root@master local]
# rpm -ivh mysql-community-server-8.0.16-2.el7.x86_64.rpm --nodeps --force
# 通過命令檢視mysql的安裝包
[root@master local]
# rpm -qa | grep mysql
mysql-community-common-8.0.16-2.el7.x86_64
mysql-community-libs-8.0.16-2.el7.x86_64
mysql-community-client-8.0.16-2.el7.x86_64
mysql-community-server-8.0.16-2.el7.x86_64
# 初始化mysql資料庫及相關配置
[root@master local]
# mysqld --initialize
# 更改所屬使用者組 如新增失敗,請先新增相應的 '組' 及 '使用者'
[root@master local]
# chown mysql:mysql /var/lib/mysql -r
# 開啟mysqld服務
[root@master local]
# systemctl start mysqld.service
# 設定開啟啟動
[root@master local]
# systemctl enable mysqld
# 查詢mysql臨時生成密碼
[root@master local]
# cat /var/log/mysqld.log | grep password
2019-06-28t10:02:12.733076z 5 [note]
[my-010454]
[server] a temporary password is generated for root@localhost: rldw%6_5j3h<
# 進入mysql登入
[root@master local]
# mysql -u root -p
# 使用上述的臨時密碼進行登入
enter password: rldw%6_5j3h<
welcome to the mysql monitor. commands end with ; or \g.
your mysql connection id is 8
server version: 8.0.16 mysql community server - gpl
# 通過命令修改登入密碼
mysql> alter user 'root'@'localhost' identified with mysql_native_password by '所要修改的密碼需包含大小寫字母、數字及特殊符號'
;
預設密碼檢查策略要求必須包含:大小寫字母、數字和特殊符號,並且長度不能少於8位,否則會提示error 1819 (hy000): your password does not satisfy the current policy requirements。
# 建立遠端訪問使用者
mysql> create user 'root'@'%' identified with mysql_native_password by '遠端訪問密碼'
;query ok, 0 rows affected (0.01 sec)
# 允許訪問許可權
mysql> grant all privileges on *.* to 'root'@'%' with grant option;
query ok, 0 rows affected (0.01 sec)
# 重新整理許可權列表
mysql> flush privileges;
query ok, 0 rows affected (0.00 sec)
至此,可通過遠端訪問賬號登入mysql使用視覺化工具。
**預設配置檔案路徑:**
配置檔案:/etc/my.cnf
日誌檔案:/var/log//var/log/mysqld.log
服務啟動指令碼:/usr/lib/systemd/system/mysqld.service
socket檔案:/var/run/mysqld/mysqld.pid
如果忘記root密碼,則按以下操作恢復:
mysql -u root
update mysql.user set authentication_string=password(
'123qwe'
) where user=
'root' and host =
'localhost'
;flush privileges
基於CentOS 7配置
配置網路 centos 7安裝完成後沒有開啟網路連線,可以更改配置檔案開啟。檢視本機ip,找到ensxx 開啟配檔案 etc sysconfig network scripts ifcfg ens33,更改內容如下,退出編輯esc儲存 w退出 q 如果不想配置靜態ip。可以只更改onboot yes...
基於Centos7的MySQL 5 7安裝
root test1 usr wget 安裝mysql源 root test1 usr yum localinstall mysql57 community release el7 8.noarch.rpm 檢查mysql源是否安裝成功 root test1 usr yum repolist ena...
基於CentOS 7 搭建 GitLab
系統要求 centos 7.2 64 位作業系統 yum update y 安裝 sshd yum install y curl policycoreutils python openssh server 啟用並啟動 sshd systemctl enable sshd systemctl star...