首先在mysql官网下载mysql的rpm安装包 ,下载地址为:https://dev.mysql.com/downloads/mysql/5.5.html#downloads
可以下载 RPM Bundle版的,这是个压缩包里面包含mysql-server、mysql-client、mysql-devel等等所有的rpm包,也可以单独下载RPM Package, MySQL Server、 RPM Package, Client Utilities、RPM Package, Development Libraries、RPM Package, Compatibility Libraries、RPM Package, Shared components(主要是这5个包,其他可以不用)
上传这5个rpm包到服务器,然后依次执行安装命令 (其中--force --nodeps 是为了强制安装,忽略本地yum repo )
rpm -ivh MySQL-server-5.5.62-1.el6.x86_64.rpm --force --nodeps
rpm -ivh MySQL-client-5.5.62-1.el6.x86_64.rpm --force --nodeps
rpm -ivh MySQL-devel-5.5.62-1.el6.x86_64.rpm --force --nodeps
rpm -ivh MySQL-shared-compat-5.5.62-1.el6.x86_64.rpm --force --nodeps
rpm -ivh MySQL-shared-5.5.62-1.el6.x86_64.rpm --force --nodeps
[root@hadoop1 data]# rpm -ivh MySQL-server-5.5.62-1.el6.x86_64.rpm --force --nodeps
warning: MySQL-server-5.5.62-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:MySQL-server ########################################### [100%]
181102 21:18:21 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
181102 21:18:21 [Note] /usr/sbin/mysqld (mysqld 5.5.62) starting as process 1844 ...
181102 21:18:21 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
181102 21:18:21 [Note] /usr/sbin/mysqld (mysqld 5.5.62) starting as process 1851 ...
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h hadoop1 password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
Please report any problems at http://bugs.mysql.com/
[root@hadoop1 data]# rpm -ivh MySQL-client-5.5.62-1.el6.x86_64.rpm --force --nodeps
warning: MySQL-client-5.5.62-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:MySQL-client ########################################### [100%]
[root@hadoop1 data]# rpm -ivh MySQL-devel-5.5.62-1.el6.x86_64.rpm --force --nodeps
warning: MySQL-devel-5.5.62-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:MySQL-devel ########################################### [100%]
[root@hadoop1 data]# rpm -ivh MySQL-shared-5.5.62-1.el6.x86_64.rpm --force --nodeps
warning: MySQL-shared-5.5.62-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:MySQL-shared ########################################### [100%]
[root@hadoop1 data]# rpm -ivh MySQL-shared-compat-5.5.62-1.el6.x86_64.rpm --force --nodeps
warning: MySQL-shared-compat-5.5.62-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:MySQL-shared-compat ########################################### [100%]
启动mysql服务
[root@hadoop1 data]# service mysql start
Starting MySQL.Logging to '/var/lib/mysql/hadoop1.err'.
. [ OK ]
将mysql添加到系统服务,开机启动
[root@hadoop1 data]# chkconfig mysql on
启动mysqladmin工具创建root用户,密码为123456
[root@hadoop1 data]# /usr/bin/mysqladmin -u root password '123456'
此时可以用root用户登录mysql了
[root@hadoop1 data]# mysql -uroot -p123456
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.62 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, 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需要支持远程访问请查看我的另一篇博客: 开启MySQL远程访问权限允许远程连接(解决Host is not allowed to connect to this MySQL server问题)