1. 程式人生 > >四、CentOS 安裝mariadb——Linux學習筆記

四、CentOS 安裝mariadb——Linux學習筆記

  A)安裝及配置

  1. 下載mariadb:
    yum -y install mariadb-server mariadb
  2. 開啟mariadb服務:
    systemctl start mariadb.service
  3. 無密碼登入mariadb:
    mysql
  4. 檢視使用者表:
    select * from mysql.user;
  5. 修改密碼和授權: grant all on *.* to 'root'@'%' identified by '123456' with grant option;update mysql.user set host = '%' where user = 'root';select host, user from user;flush privileges;
  6. 密碼登入: mysql -u root -p
  7. 設定開機啟動:systemctl enable mariadb.service

B)防火牆

  1. 停止防火牆::systemctl stop firewalld
  2. 安裝iptables-services:yum install iptables-services
  3. 設定開機啟動:

    systemctl enable iptables

              systemctl stop iptables

    systemctl start iptables
    systemctl restart iptables
    systemctl reload iptables

   4.儲存設定:

    service iptables save

  5.開放某個埠 在/etc/sysconfig/iptables裡新增:

  /sbin/iptables -A INPUT -p tcp --dport 3306 -j ACCEPT 或者

  -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3306-j ACCEPT

 

參考 

https://www.cnblogs.com/star91/p/4980024.html

https://blog.csdn.net/qq_40342287/article/details/82428048

http://blog.51cto.com/12173069/2119307

https://www.cnblogs.com/wujunbin/p/7465538.html

https://blog.csdn.net/c233728461/article/details/52679558/