RedHat6.5怎么安裝MySQL?

RedHat6.5怎么安裝mysql?下面本篇文章就來給大家介紹在RedHat6.5下安裝MySQL5.7的方法,希望對你們有所幫助。

RedHat6.5怎么安裝MySQL?

相關學習推薦:mysql教程

安裝環境:

RedHat6.5

安裝步驟:

第一步:下載

下載MySQL5.7:http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.12-1.el6.x86_64.rpm-bundle.tar

第二步:安裝

安裝前檢查服務器是否已安裝MySQL,如已安裝則將其卸載:

[root@worker1?tmp]#?rpm?-qa|grep?mysql mysql-libs-5.1.71-1.el6.x86_64 [root@worker1?tmp]#?rpm?-e?--nodeps?mysql-libs-5.1.71-1.el6.x86_64?//卸載

將下載的文件進行解壓:

[root@worker1?tmp]#?tar?-xf?mysql-5.7.12-1.el6.x86_64.rpm-bundle.tar

RedHat6.5怎么安裝MySQL?

按順序依次安裝:

rpm?-ivh?mysql-community-common-5.7.12-1.el6.x86_64.rpm rpm?-ivh?mysql-community-libs-5.7.12-1.el6.x86_64.rpm rpm?-ivh?mysql-community-devel-5.7.12-1.el6.x86_64.rpm rpm?-ivh?mysql-community-client-5.7.12-1.el6.x86_64.rpm rpm?-ivh?mysql-community-server-5.7.12-1.el6.x86_64.rpm

RedHat6.5怎么安裝MySQL?

不出意外,MySQL應該已經安裝成功。

第三步:環境變量設置

1、啟動MySQL:service mysqld start

RedHat6.5怎么安裝MySQL?

2、登錄:mysql -u root -p,初次登錄密碼為空,直接回車:

RedHat6.5怎么安裝MySQL?

為什么會出現這個錯誤,原因是因為MySQL5.7中的mysql.user 表中沒有Password字段,所以要以安全方式登錄,然后修改密碼。

解決方法如下:

修改MySQL配置文件:vim /etc/my.cnf,在文件末尾加上:skip-grant-tables,保存后重啟MySQL服務:service mysqld restart,然后重新登錄。

RedHat6.5怎么安裝MySQL?

3、修改密碼,用戶密碼是在名為mysql的database下面:

依次執行以下指令:

mysql>?use?mysql mysql>?update?user?set?password_expired='N'?where?user='root';? mysql>?update?user?set?authentication_string=password('123456')?where?user=‘root'; mysql>?flush?privileges;

注意:一定要將my.cnf配置文件之前加的跳過密碼檢測內容去掉,重啟服務;

RedHat6.5怎么安裝MySQL?

其他:

1、編碼設置:vim /etc/my.cnf,文件末尾加上編碼內容default-character-set=utf8

2、允許遠程訪問MySQL: 賦予任何主機訪問數據的權限

mysql>grant?all?privileges?on?.?to?‘root'@'%'with?grant?option;

會報錯:ERROR 1133 (42000): Can’t find any matching row in the user table

其實如果事先在mysql.user表中存在root用戶就正常了,或,將這句末尾加上identified by ‘密碼’ 也就正常了。如下面的命令行?

mysql>grant?all?privileges?on?.?to?‘root'@'%'identified?by?‘123456'?with?grant?option;

3、更改密碼策略:

mysql>?set?global?validate_password_length=0;?--更改密碼長度 mysql>?set?global?validate_password_policy=0;?--更改密碼策略為LOW

? 版權聲明
THE END
喜歡就支持一下吧
點贊14 分享