redhat6.5安裝mysql5.7

參考來源:node

http://blog.csdn.net/liyf155/article/details/61419623mysql

1.下載:sql

wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.12-1.el6.x86_64.rpm-bundle.tarvim

2.安裝:centos

[root@localhost Desktop]# rpm -qa|grep mysql  # 查看是否已安裝
mysql-libs-5.1.61-4.el6.x86_64
[root@localhost Desktop]# rpm -e --nodeps mysql-libs-5.1.61-4.el6.x86_64  #卸載安全

 

解壓:tar -xf mysql-5.7.12-1.el6.x86_64.rpm-bundle.tarbash

順序依次安裝:ide

rpm -ivh mysql-community-common-5.7.12-1.el6.x86_64.rpmui

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

安裝最後一個包的時候報錯:

error: Failed dependencies:
 libnuma.so.1()(64bit) is needed by mysql-community-server-5.7.12-1.el6.x86_64

缺乏依賴包:

numactl

下載:wget http://mirror.centos.org/centos/6/os/x86_64/Packages/numactl-2.0.9-2.el6.x86_64.rpm

安裝:rpm -ivh numactl-2.0.9-2.el6.x86_64.rpm

安裝成功

繼續上次安裝完成

 

啓動mysql服務:service mysqld start

[root@localhost mysql5.7]# service mysqld start
Initializing MySQL database:                               [  OK  ]
Installing validate password plugin:                       [  OK  ]
Starting mysqld:                                           [  OK  ]
[root@localhost mysql5.7]# 

登錄:mysql -u root -p,初次登陸密碼爲空,直接回車

[root@localhost mysql5.7]# mysql -u root -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

爲何會出現這個錯誤,緣由是由於MySQL5.7中的mysql.user 表中沒有Password字段,因此要以安全方式登陸,而後修改密碼。
解決方法以下:
修改MySQL配置文件:vim /etc/my.cnf,在文件末尾加上:skip-grant-tables,保存後重啓MySQL服務:service mysqld restart,而後從新登陸。

[root@localhost mysql5.7]# service mysqld restart
Stopping mysqld:                                           [  OK  ]
Starting mysqld:                                           [  OK  ]
[root@localhost mysql5.7]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.12 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

修改密碼:

use mysql;

update user set password_expired='N' where user='root’; 

update user set authentication_string=password('123456') where user=’root‘;

flush privileges;

修改MySQL配置文件:vim /etc/my.cnf,去掉文件末尾:skip-grant-tables

重啓MySQL服務:service mysqld restart

其餘:

  1. 編碼設置:vim /etc/my.cnf,文件末尾加上編碼內容default-character-set=utf8
  2. 容許遠程訪問MySQL:
    賦予任何主機訪問數據的權限:grant all on *.* to "root"@"%" identified by "123456";
  3. 修改密碼策略(能夠使用簡單密碼):

  set global validate_password_policy=0;

  set global validate_password_mixed_case_count=0;  

  set global validate_password_number_count=3;

  set global validate_password_special_char_count=0;

   set global validate_password_length=3;

  SHOW VARIABLES LIKE 'validate_password%';  

相關文章
相關標籤/搜索