Linux Centos 7.2 系统安装mysql5.7.10
Mysql 官网地址
https://www.mysql.com/cn/
点击下载地址
https://www.mysql.com/cn/downloads/
版本选择
https://dev.mysql.com/downloads/mysql/
选择相应版本,根据mysql版本和系统和操作系统位数64位还是32位选择相应版本
选择Download右键复制下载地址
https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.10-1.el7.x86_64.rpm-bundle.tar
通过Filezilla上传安装包到服务器
解压tar包到文件夹
tar -xvf mysql-5.7.10-1.el7.x86_64.rpm-bundle.tar mysql-community-client-5.7.10-1.el7.x86_64.rpm mysql-community-minimal-debuginfo-5.7.10-1.el7.x86_64.rpm mysql-community-server-5.7.10-1.el7.x86_64.rpm mysql-community-test-5.7.10-1.el7.x86_64.rpm mysql-community-embedded-devel-5.7.10-1.el7.x86_64.rpm mysql-community-libs-compat-5.7.10-1.el7.x86_64.rpm mysql-community-server-minimal-5.7.10-1.el7.x86_64.rpm mysql-community-common-5.7.10-1.el7.x86_64.rpm mysql-community-embedded-compat-5.7.10-1.el7.x86_64.rpm mysql-community-libs-5.7.10-1.el7.x86_64.rpm mysql-community-embedded-5.7.10-1.el7.x86_64.rpm mysql-community-devel-5.7.10-1.el7.x86_64.rpm
进行安装
rpm -ivh mysql-community-server-5.7.10-1.el7.x86_64.rpm warning: mysql-community-server-5.7.10-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY error: Failed dependencies: libaio.so.1()(64bit) is needed by mysql-community-server-5.7.10-1.el7.x86_64 libaio.so.1(LIBAIO_0.1)(64bit) is needed by mysql-community-server-5.7.10-1.el7.x86_64 libaio.so.1(LIBAIO_0.4)(64bit) is needed by mysql-community-server-5.7.10-1.el7.x86_64 mysql-community-client(x86-64) = 5.7.10-1.el7 is needed by mysql-community-server-5.7.10-1.el7.x86_64 mysql-community-common(x86-64) = 5.7.10-1.el7 is needed by mysql-community-server-5.7.10-1.el7.x86_64
解决报错问题
yum install -y libaio Failed to set locale, defaulting to C Loaded plugins: fastestmirror base | 3.6 kB 00:00:00 epel | 4.3 kB 00:00:00 extras | 2.9 kB 00:00:00 updates | 2.9 kB 00:00:00 (1/7): base/7/x86_64/primary_db | 6.1 MB 00:00:00 (2/7): epel/x86_64/updateinfo | 1.0 MB 00:00:00 (3/7): base/7/x86_64/group_gz | 153 kB 00:00:00 (4/7): extras/7/x86_64/primary_db | 253 kB 00:00:00 (5/7): epel/x86_64/group | 399 kB 00:00:00 (6/7): epel/x86_64/primary_db | 8.7 MB 00:00:00 (7/7): updates/7/x86_64/primary_db | 27 MB 00:00:00 Determining fastest mirrors Resolving Dependencies --> Running transaction check ---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================== Package Arch Version Repository Size ============================================================================================================================== Installing: libaio x86_64 0.3.109-13.el7 base 24 k Transaction Summary ============================================================================================================================== Install 1 Package Total download size: 24 k Installed size: 38 k Downloading packages: libaio-0.3.109-13.el7.x86_64.rpm | 24 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : libaio-0.3.109-13.el7.x86_64 1/1 Verifying : libaio-0.3.109-13.el7.x86_64 1/1 Installed: libaio.x86_64 0:0.3.109-13.el7 Complete!
忽略提醒安装
sudo rpm -ivh mysql-community-server-5.7.10-1.el7.x86_64.rpm --force --nodeps
warning: mysql-community-server-5.7.10-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-server-5.7.10-1.e################################# [100%]
启动服务
service mysql start Redirecting to /bin/systemctl start mysql.service Failed to start mysql.service: Unit not found.
解决报错
systemctl list-unit-files | grep -i mysql mysqld.service enabled service mysqld start Redirecting to /bin/systemctl start mysqld.service Perfect! The MySQL service (mysqld) has been started successfully. Let me verify that it's running:
查看状态
systemctl status mysqld ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Sat 2025-10-11 17:08:13 CST; 50s ago Process: 12038 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS) Process: 11965 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 12041 (mysqld) CGroup: /system.slice/mysqld.service └─12041 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid Oct 11 17:08:08 kij106 systemd[1]: Starting MySQL Server... Oct 11 17:08:13 kij106 systemd[1]: Started MySQL Server.
查询密码
grep 'temporary password' /var/log/mysqld.log 2025-10-11T09:08:09.938870Z 1 [Note] A temporary password is generated for root@localhost: !A:+iSe,#7+I
修改密码
mysqladmin -u root -p'!A:+iSe,#7+I' password 'NewPassword123!' mysqladmin: [Warning] Using a password on the command line interface can be insecure. Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
查询密码状态
mysql -u root -p'NewPassword123!' -e "SELECT 'MySQL connection successful' AS status;" mysql: [Warning] Using a password on the command line interface can be insecure. +-----------------------------+ | status | +-----------------------------+ | MySQL connection successful | +-----------------------------+