- su - //切換到root賬戶
- pacman -S mariadb //安裝mariadb
- mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql //配置啟動環(huán)境
- systemctl start mariadb //啟動服務(wù)
- mysql -u root -p //啟動mariadb
- //首次啟動沒有密碼直接回車
- use mysql;
- update user set password=PASSWORD("root") where user="root"; - //設(shè)置密碼,密碼為root
- GRANT ALL PRIVILEGES ON . TO 'root'@'%'IDENTIFIED BY '123456' WITH GRANT OPTION;//授予遠(yuǎn)程連接權(quán)限届惋,密碼為123456
- flush privileges; //刷新權(quán)限
- quit髓帽; //退出mariadb
- 如果有防火墻,需要開放遠(yuǎn)程訪問端口(Tomcat開放8080端口)
- iptables -I INPUT -p tcp --dport 3306 -j ACCEPT //開放3306端口
- iptables-save > /etc/iptables/iptables.rules // 將修改保存到防火墻
- iptables-restore < /etc/iptables/empty.rules //重置并加載規(guī)則
- 或者重新加載服務(wù): systemctl reload iptables
- 之前一直用sudo脑豹,安裝失敗郑藏,切換到root就好了。瘩欺。
- systemctl enable mariadb //開機(jī)啟動
- systemctl disable mariadb //關(guān)閉開機(jī)啟動
- sysstemctl status mariadb //檢查服務(wù)狀態(tài)