1、去官網下載MySQL,https://dev.mysql.com/downloads/mysql/5.6.html#downloads 選擇redhat6 64bit 下載rpm bundle 2、將文件拷貝到centos,解壓 tar -xvf MySQL-5.6.39-1.el6.x86_6 ...
1、去官網下載MySQL,https://dev.mysql.com/downloads/mysql/5.6.html#downloads
選擇redhat6 64bit
下載rpm bundle
2、將文件拷貝到centos,解壓 tar -xvf MySQL-5.6.39-1.el6.x86_64.rpm-bundle.tar
3、檢查是否已安裝mysql,rpm -qa|grep mysql ,如果有,運行 rpm -e 卸載
4、安裝mysql
rpm -ivh MySQL-client-5.6.39-1.el6.x86_64.rpm
rpm -ivh MySQL-devel-5.6.39-1.el6.x86_64.rpm
rpm -ivh MySQL-server-5.6.39-1.el6.x86_64.rpm
安裝MySQL-server-5.6.39-1.el6.x86_64.rpm的時候可能會報錯,缺少包
這都是因為缺少依賴的相關包造成的,解決辦法是通過yum直接安裝這些依賴包。 yum -y install libaio
yum -y install numactl
5、將配置文件拷貝到/etc目錄下,cp /usr/share/mysql/my-default.cnf /etc/my.cnf
修改配置文件 vi /etc/my.cnf 在[mysqld]下麵加上
skip-grant-tables
否則登錄時會報 錯:
[root@localhost ~]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
6、啟動mysql service mysql start
7、登錄mysql,這一步不需要輸密碼 直接輸mysql 即可,修改root密碼
mysql> update mysql.user set authentication_string=password('root') where user='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
vi /etc/my.cnf 將skip-grant-tables註釋掉
然後重啟mysql
service mysql restart
8、登錄mysql
mysql -uroot -p