1、mysql的下載
MySQL 的官網下載地址: 官網
2、mysql的安裝
- 上傳到: /usr/local/mysql
- 查看centos自帶的mysql,若存在則移除
rpm -qa | grep mysql # 查看
rpm -ev mysql-libs-* nodeps # 刪除
rpm -ivh mysql-community-client-5.7.25-1.el6.x86_64.rpm force nodeps
rpm -ivh mysql-community-common-5.7.25-1.el6.x86_64.rpm force nodeps
rpm -ivh mysql-community-libs-5.7.25-1.el6.x86_64.rpm force nodeps
rpm -ivh mysql-community-server-5.7.25-1.el6.x86_64.rpm force nodeps
–force nodeps: 表示安裝時不檢查依賴關系 # 查看mysql的狀態
service mysqld status
service mysqld start
cat /var/log/mysqld.log | more
grep pass /var/log/mysqld.log color
[root@web ~]#mysql -uroot -p
mysql> set password='Pwd@123456';
mysql> grant all privileges on *.* to 'root'@'%' identified by 'Pwd@123456';
chkconfig add mysql
# 查看是否添加成功
chkconfig list
如果上一步添加不成功,則手動添加到啟動配置文件裏
vim /etc/rc.d/rc.local
# 添加
service mysqld start
# 添加3306端口
/sbin/iptables -I INPUT -p tcp dport 3306 -j ACCEPT
# 保存
/etc/init.d/iptables save
# 重啟
service iptables restart
# 查看狀態
/etc/init.d/iptables status