1、安裝mysql官方的yum repository
[root@localhost ~]# wget -i -c
[root@localhost ~]# yum -y install mysql57-community-release-el7-10.noarch.rpm
3、安裝mysql服務
[root@localhost ~]# yum -y install mysql-community-server
執行安裝服務的時間比較長,耐心等待,中間有一次詢問y/n?輸入y回車
4、啟動mysql服務:
[root@localhost ~]# systemctl start mysqld.service
5、其他命令:
重啟:systemctl restart mysqld.service
停止:systemctl stop mysqld.service
檢視狀態:systemctl status mysqld.service
最後兩行出現:代表啟動成功。
starting mysql server...
started mysql server.
1、登入使用者:
[root@localhost ~]# mysql -u root -p
首次登入需要輸入生成的初始密碼,登陸後必須要修改這個密碼。
初始密碼在:/var/log找到mysqld.log檔案檢視其中的日誌:[note] a temporary password is generated for root@localhost: *********
2.進入mysql後:
validate_password_policy代表密碼策略,預設是1:符合長度,且必須含有數字,小寫或大寫字母,特殊字元。設定為0判斷密碼的標準就基於密碼的長度了。一定要先修改兩個引數再修改密碼
mysql> set global validate_password_policy=0;
validate_password_length代表密碼長度,最小值為4
mysql> set global validate_password_length=4;
通過命令檢視設定引數的情況:
mysql> show variables like 'validate_password%';
之後設定密碼:
mysql> alter user 'root'@'localhost' identified by '****'; //**使用者為root的密碼是****.
3、退出資料庫:
exit
以下語句代表:所有的位址都可以使用root使用者,密碼為lxh遠端訪問所有的資料庫(遠端軟體登入時一定要設定下面這句)
grant all privileges on *.* to 'root'@'%' identified by 'lxh' with grant option;
以下語句代表: ip為172.16.52.225的電腦可以使用lxh使用者,密碼為lxh遠端訪問資料庫testdb的所有表
grant all privileges on testdb.* to 'lxh'@'172.16.52.225' identified by 'lxh' with grant option;
grant all privileges on 庫名.表名 to '使用者名稱'@'ip位址' identified by '密碼' with grant option;
以下語句代表:所有的位址都可以使用root使用者,密碼為lxh遠端訪問所有的資料庫(遠端軟體登入時一定要設定下面這句)
grant all privileges on *.* to 'root'@'%' identified by 'lxh' with grant option;
最後感謝這位博主:
阿里雲伺服器安裝MySQL
安裝mysql的yum倉庫 執行以下命令 yum localinstall安裝mysql dnf install mysql community server1.啟動mysql,並檢視執行狀態 root node01 log systemctl enable mysqld root node01 l...
阿里雲伺服器安裝MySQL服務
1.確保伺服器系統處於最新狀態 root localhost yum y update 若顯示以下內容說明已經更新完成 replaced grub2.x86 64 1 2.02 0.64.el7.centos grub2 tools.x86 64 1 2.02 0.64.el7.centos com...
阿里雲伺服器CentOS下安裝mysql
安裝mysql主要有兩種方法 一種是通過原始碼自行編譯安裝,這種適合高階使用者定製mysql的特性,這裡不做說明 另一種是通過編譯過的二進位制檔案進行安裝。二進位制檔案安裝的方法又分為兩種 一種是不針對特定平台的通用安裝方法,使用的二進位制檔案是字尾為.tar.gz的壓縮檔案 第二種是使用rpm或其...