[root@itzhouq32 tools]# cat /etc/issue CentOS release 6.5 (Final) Kernel \r on an \m [root@itzhouq32 tools]# uname -a Linux itzhouq32 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
[root@itzhouq32 /]# mkdir soft [root@itzhouq32 /]# cd soft [root@itzhouq32 soft]# ls [root@itzhouq32 soft]#
若是有須要卸載
用這個查找mysql
# rpm -qa | grep mysql
用這個卸載sql
yum -y remove mysql-libs-5.1*
分別執行下面的三條命令數據庫
# wget http://dev.mysql.com/Downloads/MySQL-5.6/MySQL-server-5.6.21-1.rhel5.x86_64.rpm # wget http://dev.mysql.com/Downloads/MySQL-5.6/MySQL-devel-5.6.21-1.rhel5.x86_64.rpm # wget http://dev.mysql.com/Downloads/MySQL-5.6/MySQL-client-5.6.21-1.rhel5.x86_64.rpm
若是下載的速度太慢,也能夠使用window下載後傳輸到虛擬機的這個目錄,而後安裝。安全
# rpm -ivh MySQL-server-5.6.21-1.rhel5.x86_64.rpm
若是有如下報錯信息,須要安裝依賴包。dom
error: Failed dependencies: libaio.so.1()(64bit) is needed by MySQL-server-5.6.21-1.rhel5.x86_64 libaio.so.1(LIBAIO_0.1)(64bit) is needed by MySQL-server-5.6.21-1.rhel5.x86_64 libaio.so.1(LIBAIO_0.4)(64bit) is needed by MySQL-server-5.6.21-1.rhel5.x86_64
執行:tcp
# yum install -y libaio
再次安裝ide
# rpm -ivh MySQL-server-5.6.21-1.rhel5.x86_64.rpm
# rpm -ivh MySQL-client-5.6.21-1.rhel5.x86_64.rpm Preparing... ########################################### [100%] 1:MySQL-client ########################################### [100%]
# cp /usr/share/mysql/my-default.cnf /etc/my.cnf
# /usr/bin/mysql_install_db # /etc/init.d/mysql start # ps -ef | grep mysql # netstat -anpt | grep 3306 # more /root/.mysql_secret
而後會顯示你的數據庫隨機碼code
# The random password set for the root user at Fri Mar 15 01:43:14 2019 (local time): BKEIavP3r8C8wNoB
# mysql -uroot -pBKEIavP3r8C8wNoB
登陸成功後會顯示版本信息server
Warning: Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.6.21 Copyright (c) 2000, 2014, 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>
mysql> SET PASSWORD = PASSWORD('2626'); Query OK, 0 rows affected (0.00 sec) mysql> EXIT Bye
我設置了密碼爲2626,並退出MySQLip
# chkconfig mysql on # chkconfig mysql --list mysql 0:關閉 1:關閉 2:啓用 3:啓用 4:啓用 5:啓用 6:關閉
# service mysql status SUCCESS! MySQL running (2447)
默認狀況下MySQL爲安全起見,不支持遠程登陸MySQL,因此須要設置開啓登陸MySQL的權限。登陸MySQL後輸入命令:
mysql> grant all privileges on *.* to 'root' @'%' identified by '2626'; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
其中2626是用於遠程訪問的密碼,能夠與root密碼不同。這樣別的用戶遠程訪問你的數據庫時,能夠使用root帳號,密碼2626登陸。
[root@itzhouq32 bin]# /sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT [root@itzhouq32 bin]# /etc/rc.d/init.d/iptables save iptables:將防火牆規則保存到 /etc/sysconfig/iptables: [肯定] [root@itzhouq32 bin]#
OK,打完收工了!