1、首先查看linux版本:cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.2 (Maipo)
2.Linux查看版本說明當前CPU運行在32bit模式下, 但不代表CPU不支持64bit):
getconf LONG_BIT
64.
3.關閉防護牆
查看:
chkconfig --list | grep iptables
chkconfig iptables off (設置自動啟動為關閉)
(# chkconfig --del iptables (移除開機自動啟動))
4.當官方網站上下載對應的mysql, 根據上面信息
https://dev.mysql.com/downloads/mysql/5.5.html?os=31&version=5.1
下載(mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar)
bundle版本的 是要安裝的全部包括了,方便
5.用 ssh 工具上次的linux 上對應一個文件
[root@node04 Downloads]# ll
total 235312
-rw-r--r-- 1 root root 172994560 Oct 21 15:33 MySQL-5.5.58-1.el7.x86_64.rpm-bundle.tar
6. 注意:的是要切換的root用戶 使用 su root切換用戶
解壓之后就是出現了好多的rpm文件
解壓mysql5.5的安裝包
tar -xvf MySQL-5.5.39-2.el6.x86_64.rpm-bundle.tar
但是安裝只需要需要如下幾個文件:
[root@node04 Downloads]# ll
-rw-r--r-- 1 7155 31415 16025016 Sep 14 14:24 MySQL-client-5.5.58-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 4394260 Sep 14 14:24 MySQL-devel-5.5.58-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 47529380 Sep 14 14:24 MySQL-server-5.5.58-1.el7.x86_64.rpm
7. 利用 rpm 安裝 文件
rpm -ivh MySQL-client-5.5.58-1.el7.x86_64.rpm
rpm -ivh MySQL-devel-5.5.58-1.el7.x86_64.rpm
rpm -ivh MySQL-server-5.5.58-1.el7.x86_64.rpm
8. 接着就是初始化數據庫。十分簡單
/usr/bin/mysql_install_db
如圖:
9.接下來就是查看mysql的狀態
service mysql status
可能是應為 有進程在占用 ,或者 磁盤已滿 (查看命令df -h)
查看進程:netstat -anp | grep mysql
將里面 啟動的進程殺死 。 kill -9 進程id
11. 啟動一下
/etc/init.d/mysql start
[root@node04 Downloads]# /etc/init.d/mysql start
Starting MySQL SUCCESS!
12.進入mysql
[root@node04 Downloads]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.58 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, 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> update mysql.user set password=PASSWORD('xxxxx') where user='root'; --將root 的密碼改為 xxxx (xxxx 是你自己設置的密碼)
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> grant all on *.* to root@'%' identified by '123456' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES
-> ;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
-- 本地登錄一下,可以,遠程登錄也可以
[root@node04 Downloads]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 144
Server version: 5.5.58 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, 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>
好的,安裝成功!