linux centos7 如何安裝mysql

2022-08-23 23:36:15 字數 1708 閱讀 6665

3.檢查mysql源是否安裝成功

$ yum repolist enabled | grep "mysql.*-community.*"

4.修改yum源【可跳過】

$ vim /etc/yum.repos.d/mysql-community.repo

改變預設安裝的mysql版本。比如要安裝5.6版本,將5.7源的enabled=1改成enabled=0。然後再將5.6源的enabled=0改成enabled=1即可。

備註:enabled=1表示即將要安裝的mysql版本,這個檔案也可以不修改,預設安裝mysql最高版本

5.安裝mysql這一步才是真正安裝mysql

$ yum install mysql-community-server

6.啟動mysql服務並設定開機啟動

$ systemctl start mysqld

$ systemctl enable mysqld

$ systemctl daemon-reload

7.埠開放

$ firewall-cmd --zone=public --add-port=3306/tcp --permanent

$ firewall-cmd --reload

8.修改root本地登入密碼

1)檢視mysql密碼

$ grep 'temporary password' /var/log/mysqld.log

2)連線mysql

注意:在這一步有些系統會在輸入正確的密碼後依然會報錯:access denied for user 'root'@'localhost' (using password: yes)

解決此問題,請檢視另外一篇文章:

3)修改密碼【注意:後面的分號一定要跟上】

mysql> alter user 'root'@'localhost' identified by 'mynewpass4!';

或者:mysql> set password for 'root'@'localhost'=password('mynewpass4!'); 

9.新增遠端登入使用者

mysql> grant all privileges on *.* to 'caoxiaobo'@'%' identified by 'caoxiaobo0917!' with grant option;

10.使用客戶端連線測試

備註:這裡的使用者名稱是第9步設定的caoxiaobo,密碼為:caoxiaobo0917!

Linux Centos7下boost庫安裝

在安裝之前最好保證你的gcc是高版本的,否則有時候安裝高版本的boost會出錯。我是在root許可權下進行的這些操作。wget解壓壓縮包。tar zxvf boost 1 69 0.tar.gz進入boost 1 69 0,執行 cd boost 1 69 0 sudo bootstrap.sh p...

Linux Centos7 下Mysql的安裝

root bogon whereis mysql mysql usr bin mysql usr lib mysql usr share mysql usr share man man1 mysql.1.gz root bogon rpm qa grep mysql mysql community ...

Linux(Centos7) 如何安裝 nginx

yum install y gcc gcc c pcre pcre devel zlib zlib devel openssl openssl devel gd gd devel 說明 必須項 gcc gcc c 編譯用的 非必需 可根據實際需求來配置 pcre pcre deve rewrite模...