1.下载安装包及依赖包
MySQL :: Download MySQL Community Server (Archived Versions)
[root@localhost localrepo]# ls
MySQL-client-5.6.47-1.el7.x86_64.rpm
MySQL-server-5.6.47-1.el7.x86_64.rpm
MySQL-test-5.6.47-1.el7.x86_64.rpm
MySQL-devel-5.6.47-1.el7.x86_64.rpm
mysql-shared-5.6.47-1.el7.x86_64.rpm
MySQL-embedded-5.6.47-1.el7.x86_64.rpm
MySQL-shared-compat-5.6.47-1.el7.x86_64.rpm
2.把上述的rpm文件都使用yum -y install ./xx.rpm安装
注意: client和server的rpm包应该在最后安装
比如:
[root@localhost ~]# yum -y install MySQL-embedded.x86_64
仓库 'local_repo' 在配置中缺少名称,将使用 id。
上次元数据过期检查:0:00:34 前,执行于 2024年08月23日 星期五 13时21分33秒。
错误:
问题: 冲突的请求
- 没有东西可提供 libncurses.so.5()(64bit)(MySQL-embedded-5.6.47-1.el7.x86_64 需要)
- 没有东西可提供 libtinfo.so.5()(64bit)(MySQL-embedded-5.6.47-1.el7.x86_64 需要)
(尝试添加 '--skip-broken' 来跳过无法安装的软件包 或 '--nobest' 来不只使用软件包的最佳候选)
[root@localhost ~]# yum -y install MySQL-shared.x86_64
仓库 'local_repo' 在配置中缺少名称,将使用 id。
上次元数据过期检查:0:00:51 前,执行于 2024年08月23日 星期五 13时21分33秒。
依赖关系解决。
=============================================================================================================================================================
软件包 架构 版本 仓库 大小
=============================================================================================================================================================
安装:
MySQL-shared x86_64 5.6.47-1.el7 local_repo 4.1 M
事务概要
=============================================================================================================================================================
安装 1 软件包
总计:4.1 M
安装大小:17 M
下载软件包:
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
准备中 : 1/1
安装 : MySQL-shared-5.6.47-1.el7.x86_64 1/1
运行脚本: MySQL-shared-5.6.47-1.el7.x86_64 1/1
验证 : MySQL-shared-5.6.47-1.el7.x86_64 1/1
已安装:
MySQL-shared-5.6.47-1.el7.x86_64
完毕!
注意: 有警告需要安装 libtinfo.so.5
[root@localhost ~]# yum provides libtinfo.so.5
仓库 'app' 在配置中缺少名称,将使用 id。
仓库 'base' 在配置中缺少名称,将使用 id。
仓库 'local_repo' 在配置中缺少名称,将使用 id。
app 128 MB/s | 7.8 MB 00:00
base 107 MB/s | 2.6 MB 00:00
local_repo 1.7 MB/s | 63 kB 00:00
ncurses-compat-libs-6.1-9.20180224.el8.i686 : Ncurses compatibility libraries
仓库 :base
匹配来源:
提供 : libtinfo.so.5
[root@localhost ~]# yum -y install ncurses-compat-libs-6.1-9.20180224.el8.i686
仓库 'app' 在配置中缺少名称,将使用 id。
仓库 'base' 在配置中缺少名称,将使用 id。
仓库 'local_repo' 在配置中缺少名称,将使用 id。
上次元数据过期检查:0:00:16 前,执行于 2024年08月23日 星期五 13时23分56秒。
依赖关系解决。
=============================================================================================================================================================
软件包 架构 版本 仓库 大小
=============================================================================================================================================================
安装:
ncurses-compat-libs i686 6.1-9.20180224.el8 base 346 k
安装依赖关系:
glibc i686 2.28-189.1.el8 base 2.0 M
libgcc i686 8.5.0-10.el8 base 86 k
libstdc++ i686 8.5.0-10.el8 base 489 k
事务概要
=============================================================================================================================================================
安装 4 软件包
总计:2.9 M
安装大小:7.9 M
下载软件包:
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
准备中 : 1/1
安装 : libgcc-8.5.0-10.el8.i686 1/4
运行脚本: libgcc-8.5.0-10.el8.i686 1/4
运行脚本: glibc-2.28-189.1.el8.i686 2/4
安装 : glibc-2.28-189.1.el8.i686 2/4
运行脚本: glibc-2.28-189.1.el8.i686 2/4
安装 : libstdc++-8.5.0-10.el8.i686 3/4
运行脚本: libstdc++-8.5.0-10.el8.i686 3/4
安装 : ncurses-compat-libs-6.1-9.20180224.el8.i686 4/4
运行脚本: ncurses-compat-libs-6.1-9.20180224.el8.i686 4/4
验证 : glibc-2.28-189.1.el8.i686 1/4
验证 : libgcc-8.5.0-10.el8.i686 2/4
验证 : libstdc++-8.5.0-10.el8.i686 3/4
验证 : ncurses-compat-libs-6.1-9.20180224.el8.i686 4/4
已安装:
glibc-2.28-189.1.el8.i686 libgcc-8.5.0-10.el8.i686 libstdc++-8.5.0-10.el8.i686 ncurses-compat-libs-6.1-9.20180224.el8.i686
完毕!
3.继续安装rpm包
4.最后安装server的rpm包会提示临时密码:
[root@localhost localrepo]# yum -y install MySQL-server-5.6.47-1.el7.x86_64.rpm
仓库 'app' 在配置中缺少名称,将使用 id。
仓库 'base' 在配置中缺少名称,将使用 id。
仓库 'local_repo' 在配置中缺少名称,将使用 id。
上次元数据过期检查:0:03:18 前,执行于 2024年08月23日 星期五 13时23分56秒。
依赖关系解决。
=============================================================================================================================================================
软件包 架构 版本 仓库 大小
=============================================================================================================================================================
安装:
MySQL-server x86_64 5.6.47-1.el7 @commandline 86 M
事务概要
=============================================================================================================================================================
安装 1 软件包
总计:86 M
安装大小:351 M
下载软件包:
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
准备中 : 1/1
运行脚本: MySQL-server-5.6.47-1.el7.x86_64 1/1
安装 : MySQL-server-5.6.47-1.el7.x86_64 1/1
警告:user mysql does not exist - using root
警告:group mysql does not exist - using root
警告:user mysql does not exist - using root
警告:group mysql does not exist - using root
运行脚本: MySQL-server-5.6.47-1.el7.x86_64 1/1
user2024-08-23 13:27:39 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2024-08-23 13:27:39 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2024-08-23 13:27:39 0 [Note] /usr/sbin/mysqld (mysqld 5.6.47) starting as process 19903 ...
2024-08-23 13:27:39 19903 [Note] InnoDB: Using atomics to ref count buffer pool pages
2024-08-23 13:27:39 19903 [Note] InnoDB: The InnoDB memory heap is disabled
2024-08-23 13:27:39 19903 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2024-08-23 13:27:39 19903 [Note] InnoDB: Memory barrier is not used
2024-08-23 13:27:39 19903 [Note] InnoDB: Compressed tables use zlib 1.2.11
2024-08-23 13:27:39 19903 [Note] InnoDB: Using Linux native AIO
2024-08-23 13:27:39 19903 [Note] InnoDB: Using CPU crc32 instructions
2024-08-23 13:27:39 19903 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2024-08-23 13:27:39 19903 [Note] InnoDB: Completed initialization of buffer pool
2024-08-23 13:27:39 19903 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2024-08-23 13:27:39 19903 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2024-08-23 13:27:39 19903 [Note] InnoDB: Database physically writes the file full: wait...
2024-08-23 13:27:40 19903 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2024-08-23 13:27:40 19903 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2024-08-23 13:27:41 19903 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2024-08-23 13:27:41 19903 [Warning] InnoDB: New log files created, LSN=45781
2024-08-23 13:27:41 19903 [Note] InnoDB: Doublewrite buffer not found: creating new
2024-08-23 13:27:41 19903 [Note] InnoDB: Doublewrite buffer created
2024-08-23 13:27:41 19903 [Note] InnoDB: 128 rollback segment(s) are active.
2024-08-23 13:27:41 19903 [Warning] InnoDB: Creating foreign key constraint system tables.
2024-08-23 13:27:41 19903 [Note] InnoDB: Foreign key constraint system tables created
2024-08-23 13:27:41 19903 [Note] InnoDB: Creating tablespace and datafile system tables.
2024-08-23 13:27:41 19903 [Note] InnoDB: Tablespace and datafile system tables created.
2024-08-23 13:27:41 19903 [Note] InnoDB: Waiting for purge to start
2024-08-23 13:27:41 19903 [Note] InnoDB: 5.6.47 started; log sequence number 0
2024-08-23 13:27:41 19903 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work.
2024-08-23 13:27:41 19903 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.
2024-08-23 13:27:41 19903 [Note] Binlog end
2024-08-23 13:27:41 19903 [Note] InnoDB: FTS optimize thread exiting.
2024-08-23 13:27:41 19903 [Note] InnoDB: Starting shutdown...
2024-08-23 13:27:43 19903 [Note] InnoDB: Shutdown completed; log sequence number 1625977
A random root password has been set. You will find it in '/root/.mysql_secret'.
2024-08-23 13:27:43 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2024-08-23 13:27:43 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2024-08-23 13:27:43 0 [Note] /usr/sbin/mysqld (mysqld 5.6.47) starting as process 19949 ...
2024-08-23 13:27:43 19949 [Note] InnoDB: Using atomics to ref count buffer pool pages
2024-08-23 13:27:43 19949 [Note] InnoDB: The InnoDB memory heap is disabled
2024-08-23 13:27:43 19949 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2024-08-23 13:27:43 19949 [Note] InnoDB: Memory barrier is not used
2024-08-23 13:27:43 19949 [Note] InnoDB: Compressed tables use zlib 1.2.11
2024-08-23 13:27:43 19949 [Note] InnoDB: Using Linux native AIO
2024-08-23 13:27:43 19949 [Note] InnoDB: Using CPU crc32 instructions
2024-08-23 13:27:43 19949 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2024-08-23 13:27:43 19949 [Note] InnoDB: Completed initialization of buffer pool
2024-08-23 13:27:43 19949 [Note] InnoDB: Highest supported file format is Barracuda.
2024-08-23 13:27:43 19949 [Note] InnoDB: 128 rollback segment(s) are active.
2024-08-23 13:27:43 19949 [Note] InnoDB: Waiting for purge to start
2024-08-23 13:27:43 19949 [Note] InnoDB: 5.6.47 started; log sequence number 1625977
2024-08-23 13:27:43 19949 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work.
2024-08-23 13:27:43 19949 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.
2024-08-23 13:27:43 19949 [Note] Binlog end
2024-08-23 13:27:43 19949 [Note] InnoDB: FTS optimize thread exiting.
2024-08-23 13:27:43 19949 [Note] InnoDB: Starting shutdown...
2024-08-23 13:27:45 19949 [Note] InnoDB: Shutdown completed; log sequence number 1625987
...
A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.
You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.
Also, the account for the anonymous user has been removed.
In addition, you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test database.
This is strongly recommended for production servers.
See the manual for more instructions.
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
New default config file was created as /usr/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
验证 : MySQL-server-5.6.47-1.el7.x86_64 1/1
已安装:
MySQL-server-5.6.47-1.el7.x86_64
完毕!
5.查看临时密码并使用该密码登录
[root@localhost localrepo]# cat /root/.mysql_secret
# The random password set for the root user at Fri Aug 23 13:27:41 2024 (local time): DY3Hus8E7ntGHzPY
[root@localhost localrepo]# mysql -uroot -p"DY3Hus8E7ntGHzPY"
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.47
Copyright (c) 2000, 2020, 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>
注意: 临时密码不可久用,需要及时修改密码
[root@localhost localrepo]# mysqladmin -uroot -p"DY3Hus8E7ntGHzPY" password "123456"
6.使用新密码登录
[root@localhost localrepo]# mysql -uroot -p123456
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.6.47 MySQL Community Server (GPL)
Copyright (c) 2000, 2020, 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> exit
Bye
注意: 上述方法却不能实现mysql -uroot -h IP地址 -p123456登录,提示没有权限
7.赋权
[root@localhost localrepo]# mysql -uroot -p123456
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.6.47 MySQL Community Server (GPL)
Copyright (c) 2000, 2020, 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> create user "root"@"%" identified by "123456";
Query OK, 0 rows affected (0.00 sec)
mysql> grant all on *.* to "root"@"%";
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
8.登录时加上ip再试试
[root@localhost localrepo]# mysql -uroot -h192.168.137.102 -p123456
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.6.47 MySQL Community Server (GPL)
Copyright (c) 2000, 2020, 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>