官方安裝說明mysql
添加源sql
vi /etc/yum.repos.d/MariaDB.repo [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.2/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
安裝數據庫
yum install MariaDB-server
防火牆設置centos
firewall-cmd --zone=public --permanent --add-service=mysql firewall-cmd --reload
啓動安全
systemctl start mariadb
開機自啓動url
systemctl enable mariadb
安全設置centos7
mysql_secure_installation //初始安裝root是空密碼,直接回車 Enter current password for root (enter for none): //設置新密碼 Set root password? [Y/n] Y New password: *** Re-enter new password: *** //是否刪除匿名用戶 Remove anonymous users? [Y/n] Y //禁止root遠程登陸 Disallow root login remotely? [Y/n] Y //刪除test數據庫 Remove test database and access to it? [Y/n] Y //從新加載權限表 Reload privilege tables now? [Y/n] Y
爲安全root僅限本地登陸,根據須要能夠新建一個有管理員權限的遠程用戶code
mysql -uroot -p GRANT ALL PRIVILEGES ON *.* TO '用戶名'@'%' IDENTIFIED BY '登陸密碼' WITH GRANT OPTION; FLUSH PRIVILEGES; exit;