RHEL6.5安裝MySQL8.0
之前曾經寫過關於RHEL6.5的安裝還有網絡yum的配置不會的請參考以下兩篇文章
系統安裝https://www.cnblogs.com/lch1990/p/10310304.html
yum配置https://www.cnblogs.com/lch1990/p/10299714.html
好了既然要裝mysql我們就去mysql官網下載最新的安裝包吧
或者你可以將此處的鏈接複製出來直接在RHEL上面wget一下直接上命令吧
[root@localhost ~]# mkdir /download
[root@localhost ~]# cd /download/
[root@localhost download]# yum -y install wget
解壓安裝吧
[root@localhost download]# ls
mysql-8.0.14-1.el6.x86_64.rpm-bundle.tar
[root@localhost download]# tar -xf mysql-8.0.14-1.el6.x86_64.rpm-bundle.tar
[root@localhost download]# ll
total 1054088
-rw-r--r--. 1 root root 539688960 Dec 21 22:46 mysql-8.0.14-1.el6.x86_64.rpm-bundle.tar
-rw-r--r--. 1 7155 31415 28906092 Dec 21 22:02 mysql-community-client-8.0.14-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415 705796 Dec 21 22:02 mysql-community-common-8.0.14-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415 4258896 Dec 21 22:02 mysql-community-devel-8.0.14-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415 2542980 Dec 21 22:03 mysql-community-libs-8.0.14-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415 1769300 Dec 21 22:03 mysql-community-libs-compat-8.0.14-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415 414593048 Dec 21 22:03 mysql-community-server-8.0.14-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415 86904716 Dec 21 22:04 mysql-community-test-8.0.14-1.el6.x86_64.rpm
CentOS 6.5會自帶 MySQL,需要先卸載,查看原來安裝的 MySQL
rpm -qa | grep mysql
MySQL 卸載
複製rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64
解壓後會有幾個安裝包,按順序安裝
複製rpm -ivh mysql-community-common-8.0.14-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.14-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-compat-8.0.14-1.el6.x86_64.rpm
rpm -ivh mysql-community-client-8.0.14-1.el6.x86_64.rpm
rpm -ivh mysql-community-server-8.0.14-1.el6.x86_64.rpm
[root@localhost download]# service mysqld status
mysqld is stopped
[root@localhost download]# service mysqld start
Starting mysqld: [ OK ]
修改MySQL配置文件:vim /etc/my.cnf,在文件末尾加上:skip-grant-tables,保存後重啓MySQL服務:service mysqld restart,然後重新登錄
[root@localhost download]# cat /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
skip-grant-tables
[root@localhost download]# service mysqld restart
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
[root@localhost download]#
接下來我們就可以登錄了(首次登錄沒有密碼直接回車)
[root@localhost download]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.14 MySQL Community Server - GPL
Copyright (c) 2000, 2019, 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> alter user'root'@'%' IDENTIFIED BY '123456';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql> flush privileges;
Query OK, 0 rows affected (0.06 sec)
mysql> ALTER user 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.04 sec)
額這個我也沒想到多次嘗試才發現,居然只需要刷新一下權限就可以進行修改了。那麼既然修改成功了爲了安全起見那我們就吧配置文件中的skip-grant-tables刪掉並重啓服務吧
mysql> flush privileges;
Query OK, 0 rows affected (0.05 sec)
mysql> GRANT ALL ON *.* TO 'root'@'%';
ERROR 1410 (42000): You are not allowed to create a user with GRANT
mysql> CREATE USER 'root'@'%' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.06 sec)
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.03 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
Query OK, 0 rows affected (0.02 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
到這裏授權就算搞定了要想連接還需要配置防火牆我這裏就直接關閉防火牆了
[root@localhost ~]# service iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
詳細查看這兩篇文章:
https://www.cnblogs.com/lch1990/p/10313116.html
https://www.cnblogs.com/newRyan/p/12186671.html