标签:11 x86 5.7 安装 mysql 64 linux rpm
linux 下安装 mysql
1 相关参数
系统 : CentOS release 6.8 (Final)
mysql : mysql-5.7.11
2 检查系统环境
检查 mysql 库文件是否存在,存在则进行删除;
[root@localhost software]# rpm -qa | grep mysql
mysql-libs-5.1.73-7.el6.x86_64
[root@localhost software]# rpm -e mysql-libs-5.1.73-7.el6.x86_64 --nodeps
[root@localhost software]# ll
total 535352
-rw-r--r--. 1 root root 548193637 Mar 12 06:06 mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz
[root@localhost software]# rpm -qa | grep mysql
[root@localhost software]#
3 准备安装包
官网下载: https://downloads.mysql.com/archives/community/
选择版本:
产品版本:5.7.11
系统 :Red Hat Enterprise Linux / Oracle Linux
系统版本:Red Hat Enterprise Linux6 / Oracle Linux 6(x86,64-bit)
右键点击 Download 选择复制地址, 使用命令:wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.11-1.el6.x86_64.rpm-bundle.tar
[root@localhost software]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.11-1.el6.x86_64.rpm-bundle.tar
--2020-03-12 06:37:51-- https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.11-1.el6.x86_64.rpm-bundle.tar
Resolving downloads.mysql.com... 137.254.60.14
Connecting to downloads.mysql.com|137.254.60.14|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.11-1.el6.x86_64.rpm-bundle.tar [following]
--2020-03-12 06:37:56-- https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.11-1.el6.x86_64.rpm-bundle.tar
Resolving cdn.mysql.com... 23.193.25.9
Connecting to cdn.mysql.com|23.193.25.9|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 439500800 (419M) [application/x-tar]
Saving to: “mysql-5.7.11-1.el6.x86_64.rpm-bundle.tar”
2% [===> ] 9,332,973 322K/s eta 23m 33s
4 安装
下载完成之后解压,命令:tar xvf mysql-5.7.11-1.el6.x86_64.rpm-bundle.tar
[root@localhost software]# tar xvf mysql-5.7.11-1.el6.x86_64.rpm-bundle.tar
mysql-community-embedded-5.7.11-1.el6.x86_64.rpm
mysql-community-common-5.7.11-1.el6.x86_64.rpm
mysql-community-test-5.7.11-1.el6.x86_64.rpm
mysql-community-client-5.7.11-1.el6.x86_64.rpm
mysql-community-embedded-devel-5.7.11-1.el6.x86_64.rpm
mysql-community-server-5.7.11-1.el6.x86_64.rpm
mysql-community-devel-5.7.11-1.el6.x86_64.rpm
mysql-community-libs-5.7.11-1.el6.x86_64.rpm
mysql-community-libs-compat-5.7.11-1.el6.x86_64.rpm
[root@localhost software]# ll
total 1393756
-rw-r--r--. 1 root root 439500800 Feb 2 2016 mysql-5.7.11-1.el6.x86_64.rpm-bundle.tar
-rw-r--r--. 1 7155 wheel 24176228 Feb 2 2016 mysql-community-client-5.7.11-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 wheel 333480 Feb 2 2016 mysql-community-common-5.7.11-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 wheel 3854020 Feb 2 2016 mysql-community-devel-5.7.11-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 wheel 38247128 Feb 2 2016 mysql-community-embedded-5.7.11-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 wheel 130605584 Feb 2 2016 mysql-community-embedded-devel-5.7.11-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 wheel 2237704 Feb 2 2016 mysql-community-libs-5.7.11-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 wheel 1722544 Feb 2 2016 mysql-community-libs-compat-5.7.11-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 wheel 141256272 Feb 2 2016 mysql-community-server-5.7.11-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 wheel 97051252 Feb 2 2016 mysql-community-test-5.7.11-1.el6.x86_64.rpm
接着使用rpm 命令依次安装:
rpm -ivh mysql-community-libs-5.7.11-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.11-1.el6.x86_64.rpm
rpm -ivh mysql-community-common-5.7.11-1.el6.x86_64.rpm
rpm -ivh mysql-community-embedded-5.7.11-1.el6.x86_64.rpm
rpm -ivh mysql-community-devel-5.7.11-1.el6.x86_64.rpm
rpm -ivh mysql-community-embedded-devel-5.7.11-1.el6.x86_64.rpm
rpm -ivh mysql-community-client-5.7.11-1.el6.x86_64.rpm
rpm -ivh mysql-community-server-5.7.11-1.el6.x86_64.rpm
rpm -ivh mysql-community-test-5.7.11-1.el6.x86_64.rpm
窗口
[root@localhost software]# rpm -ivh mysql-community-libs-5.7.11-1.el6.x86_64.rpm
warning: mysql-community-libs-5.7.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-libs ########################################### [100%]
[root@localhost software]# rpm -ivh mysql-community-libs-compat-5.7.11-1.el6.x86_64.rpm
warning: mysql-community-libs-compat-5.7.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-libs-co########################################### [100%]
[root@localhost software]# rpm -ivh mysql-community-common-5.7.11-1.el6.x86_64.rpm
warning: mysql-community-common-5.7.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
package mysql-community-common-5.7.11-1.el6.x86_64 is already installed
[root@localhost software]# rpm -ivh mysql-community-embedded-5.7.11-1.el6.x86_64.rpm
warning: mysql-community-embedded-5.7.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-embedde########################################### [100%]
[root@localhost software]# rpm -ivh mysql-community-devel-5.7.11-1.el6.x86_64.rpm
warning: mysql-community-devel-5.7.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-devel ########################################### [100%]
[root@localhost software]# rpm -ivh mysql-community-embedded-devel-5.7.11-1.el6.x86_64.rpm
warning: mysql-community-embedded-devel-5.7.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-embedde########################################### [100%]
[root@localhost software]# rpm -ivh mysql-community-client-5.7.11-1.el6.x86_64.rpm
warning: mysql-community-client-5.7.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-client ########################################### [100%]
[root@localhost software]# rpm -ivh mysql-community-server-5.7.11-1.el6.x86_64.rpm
warning: mysql-community-server-5.7.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
package mysql-community-server-5.7.11-1.el6.x86_64 is already installed
[root@localhost software]#
[root@localhost software]# rpm -ivh mysql-community-test-5.7.11-1.el6.x86_64.rpm
warning: mysql-community-test-5.7.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
perl(Time::HiRes) is needed by mysql-community-test-5.7.11-1.el6.x86_64
[root@localhost software]# yum -y install perl perl-devel libaio libaio-devel perl-Time-HiRes
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: mirrors.huaweicloud.com
* extras: mirrors.huaweicloud.com
* updates: mirrors.tuna.tsinghua.edu.cn
Package libaio-0.3.107-10.el6.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package libaio-devel.x86_64 0:0.3.107-10.el6 will be installed
......
.....
Complete!
如果出现安装错误,缺少依赖的情况,根据提示安装即可;
yum -y install perl perl-devel libaio libaio-devel perl-Time-HiRes
全部安装完成以后,尝试启动 mysql 服务:service mysqld start
[root@localhost software]# service mysqld start
Initializing MySQL database: [ OK ]
Installing validate password plugin: [ OK ]
Starting mysqld: [ OK ]
5 密码
打开配置文件,找到日志的的目录,命令:cat /etc/my.cnf
[root@localhost local]# cat /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/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 leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# 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
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
即,log-error=/var/log/mysqld.log
找到日志,其中 JC*VnGZd 即为初始密码。
2020-03-12T14:31:44.591465Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-03-12T14:31:44.775049Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-03-12T14:31:44.963796Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-03-12T14:31:45.310650Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 3301033c-646e-11ea-9e94-000c29a87561.
2020-03-12T14:31:45.327760Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-03-12T14:31:45.362722Z 1 [Note] A temporary password is generated for root@localhost: JC<F0>*VnGZd
重置密码,使用安全设置, /usr/bin/mysql_secure_installation
[root@localhost local]# /usr/bin/mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:
The existing password for the user account root has expired. Please set a new password.
New password:
Re-enter new password:
he 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
Using existing password for root.
Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y
New password:
Re-enter new password:
Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n
... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
[root@localhost local]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.7.11 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
6 设置字符集
打开 mysql 的配置文件: vim /etc/my.cnf
在 [mysqld] 下添加:
default-storage-engine=INNODB
character-set-server=utf8
collation-server=utf8_general_ci
保存重启后,即可设置成为utf8字符集。
root@localhost ~]# vim /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[client]
default-character-set = utf8
[mysql]
default-character-set = utf8
[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 leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# 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
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
default-storage-engine=INNODB
character-set-server=utf8
collation-server=utf8_general_ci
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
远程连接:
1 记得不要使用root用户,新建一个账户。
2 服务器防护墙开放 mysql 服务端口 3306。
标签:11,x86,5.7,安装,mysql,64,linux,rpm 来源: https://blog.csdn.net/zhanyufeng888/article/details/104816887
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。