1.环境介绍
OS: Redhat Linuix 6.5
MySQL: mysql-5.7.21-1.el6.x86_64.rpm-bundle.tar
2.系统设置
2.1 selinuix修改
[root@localhost mysql]# vi /etc/selinux/config
SELINUX=disabled
3.检查系统中是否带有mysql
[root@localhost soft]# rpm -qa| grep mysql
mysql-libs-5.1.71-1.el6.x86_64
[root@localhost soft]# rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64
4.安装
[root@localhost mysql]# tar -xvf mysql-5.7.21-1.el6.x86_64.rpm-bundle.tar
mysql-community-libs-5.7.21-1.el6.x86_64.rpm
mysql-community-devel-5.7.21-1.el6.x86_64.rpm
mysql-community-server-5.7.21-1.el6.x86_64.rpm
mysql-community-test-5.7.21-1.el6.x86_64.rpm
mysql-community-embedded-5.7.21-1.el6.x86_64.rpm
mysql-community-client-5.7.21-1.el6.x86_64.rpm
mysql-community-libs-compat-5.7.21-1.el6.x86_64.rpm
mysql-community-common-5.7.21-1.el6.x86_64.rpm
mysql-community-embedded-devel-5.7.21-1.el6.x86_64.rpm
--使用nodeps避免包冲突
rpm -ivh mysql-community-server-5.7.21-1.el6.x86_64.rpm --nodeps
OS: Redhat Linuix 6.5
MySQL: mysql-5.7.21-1.el6.x86_64.rpm-bundle.tar
2.系统设置
2.1 selinuix修改
[root@localhost mysql]# vi /etc/selinux/config
SELINUX=disabled
3.检查系统中是否带有mysql
[root@localhost soft]# rpm -qa| grep mysql
mysql-libs-5.1.71-1.el6.x86_64
[root@localhost soft]# rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64
4.安装
[root@localhost mysql]# tar -xvf mysql-5.7.21-1.el6.x86_64.rpm-bundle.tar
mysql-community-libs-5.7.21-1.el6.x86_64.rpm
mysql-community-devel-5.7.21-1.el6.x86_64.rpm
mysql-community-server-5.7.21-1.el6.x86_64.rpm
mysql-community-test-5.7.21-1.el6.x86_64.rpm
mysql-community-embedded-5.7.21-1.el6.x86_64.rpm
mysql-community-client-5.7.21-1.el6.x86_64.rpm
mysql-community-libs-compat-5.7.21-1.el6.x86_64.rpm
mysql-community-common-5.7.21-1.el6.x86_64.rpm
mysql-community-embedded-devel-5.7.21-1.el6.x86_64.rpm
--使用nodeps避免包冲突
rpm -ivh mysql-community-server-5.7.21-1.el6.x86_64.rpm --nodeps
rpm -ivh mysql-community-client-5.7.21-1.el6.x86_64.rpm --nodeps
rpm -ivh mysql-community-common-5.7.21-1.el6.x86_64.rpm --nodeps
Starting mysqld: [ OK ]
5.mysql安全设置
5.1 查看密码
[root@localhost log]# cat mysqld.log | grep password
2018-01-21T13:27:36.164705Z 1 [Note] A temporary password is generated for root@localhost: T&DH+Ij*H9kd
5.2.<span white-space:normal;background-color:#f8f8f8;"="">安全设置
[root@localhost log]# /usr/bin/mysql_secure_installation
Enter password for user root:
The existing password for the user account root has expired. Please set a new password.
New password:
5.3 登录成功
[root@localhost log]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 24
Server version: 5.7.21 MySQL Community Server (GPL)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.02 sec)
rpm -ivh mysql-community-common-5.7.21-1.el6.x86_64.rpm --nodeps
rpm -ivh mysql-community-devel-5.7.21-1.el6.x86_64.rpm --nodeps
rpm -ivh mysql-community-embedded-5.7.21-1.el6.x86_64.rpm --nodeps
rpm -ivh mysql-community-embedded-devel-5.7.21-1.el6.x86_64.rpm --nodeps
rpm -ivh mysql-community-libs-5.7.21-1.el6.x86_64.rpm --nodeps
rpm -ivh mysql-community-libs-compat-5.7.21-1.el6.x86_64.rpm --nodeps
rpm -ivh mysql-community-test-5.7.21-1.el6.x86_64.rpm --nodeps
--启动mysql
[root@localhost soft]# mkdir -p /mysql/data
[root@localhost soft]# mkdir -p /mysql/log/
[root@localhost soft]# mkdir -p /mysql/run/mysqld
[root@localhost soft]# vi /etc/my.cnf
datadir=/mysql/datasocket=/mysql/mysql.sock
log-error=/mysql/log/mysqld.log
pid-file=/mysql/run/mysqld/mysqld.pid
[root@localhost log]# /etc/init.d/mysqld start
Initializing MySQL database: [ OK ]
rpm -ivh mysql-community-embedded-5.7.21-1.el6.x86_64.rpm --nodeps
rpm -ivh mysql-community-embedded-devel-5.7.21-1.el6.x86_64.rpm --nodeps
rpm -ivh mysql-community-libs-5.7.21-1.el6.x86_64.rpm --nodeps
rpm -ivh mysql-community-libs-compat-5.7.21-1.el6.x86_64.rpm --nodeps
rpm -ivh mysql-community-test-5.7.21-1.el6.x86_64.rpm --nodeps
--启动mysql
[root@localhost soft]# mkdir -p /mysql/data
[root@localhost soft]# mkdir -p /mysql/log/
[root@localhost soft]# mkdir -p /mysql/run/mysqld
[root@localhost soft]# vi /etc/my.cnf
datadir=/mysql/data
log-error=/mysql/log/mysqld.log
pid-file=/mysql/run/mysqld/mysqld.pid
[root@localhost log]# /etc/init.d/mysqld start
Starting mysqld: [ OK ]
5.mysql安全设置
5.1 查看密码
[root@localhost log]# cat mysqld.log | grep password
2018-01-21T13:27:36.164705Z 1 [Note] A temporary password is generated for root@localhost: T&DH+Ij*H9kd
5.2.<span white-space:normal;background-color:#f8f8f8;"="">安全设置
[root@localhost log]# /usr/bin/mysql_secure_installation
Enter password for user root:
The existing password for the user account root has expired. Please set a new password.
New password:
5.3 登录成功
[root@localhost log]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 24
Server version: 5.7.21 MySQL Community Server (GPL)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.02 sec)