1. 程式人生 > >安裝MariaDB資料(RHEL7環境)

安裝MariaDB資料(RHEL7環境)

 配置妥當yum庫就可以安裝MariaDB資料庫的主程式和服務端程式了。

1.安裝:yum install mariadb mariadb-server

2.啟動 :  systemctl start mariadb  (啟動後先不要立即使用,要先對資料庫程式進行初始)

3.初始化操作:mysql_secure_install

        Enter current password for root (enter for none): 當前資料庫密碼為空,直接回車

                       Set root password? [Y/n]:y 輸入為root管理員設定的資料庫密碼,然後再次確認密碼

                       Remove anonymous users? [Y/n]:y 刪除匿名使用者

        Disallow root login remotely? [Y/n]:y 禁止root管理員從遠端登入

        Remove test database and access to it? [Y/n]:y 刪除test資料庫並取消對它的訪問許可權

                       

Reload privilege tables now? [Y/n]:y 重新整理授權表,讓初始化的設定立即生效

(4).在很多生產環境中需要使網站和資料庫分離,如果需要讓root管理員遠端訪問資料庫,可在3.步的初始化中設定策略允許root管理員遠端訪問資料庫。然後設定防火牆,使它放行對資料庫服務程式(mysql)的訪問請求:#firewall-cmd --permanent --add-service mysql

    #firewall-cmd --reload

我遇到的問題:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

這個錯誤是由密碼錯誤引起的,可以重置密碼:

1.重置密碼的第一步就是跳過MySQL的密碼認證過程

#vim /etc/my.cn

在[mysqld]文字段下任意一行新增“skip-grant-tables”用來跳過密碼驗證的過程

2.重啟MySQL

3.進入mysql,重置密碼,重新整理授權表

#mysql

#update user set password=password("你的新密碼") where user="root";

#flush privileges;

4.將/etc/my.cnf文件中新增的內容去掉