linux安装mysql出错点service mysqld start mysqld: unrecognized service 和Error Downloading Packages:

在Linux环境中安装MySQL时遇到'service mysqld start'提示未识别服务以及下载包时出错的问题。解决方法包括:检查并移除已安装的MySQL,下载mysql5.7的RPM包,执行安装,启动服务。在第五步下载过程中出现问题,可能是由于网络连接不稳定导致。确保虚拟机联网后重新执行下载和安装步骤,最终成功启动MySQL服务。

Mysql安装

1.检测系统是否自带安装mysql
yum list installed | grep mysql
2.删除系统自带mysql,删除(所有以mysql开头的都删除)
yum remove mysql mysql-server mysql-libs
3.下载mysql5.7 rpm包
wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
4.执行rpm
rpm -ivh mysql-community-release-el6-5.noarch.rpm
5.安装mysql 服务器命令(一路yes)
yum install mysql-community-server
6.启动mysql服务
service mysqld start
其他步骤设置密码,开机自动启动,开启mysql外网访问就。。。。。

按着步骤来走到第六步出错:

service mysqld start
mysqld: unrecognized service

然后回看自己前面执行的代码发现第五步执行过程有错误:

Downloading Packages:
(1/5): mysql-community-client-5.6.45-2.el6.x86_64.rpm         |  18 MB     00:32     
http://repo.mysql.com/yum/mysql-5.6-community/el/6/x86_64/mysql-community-common-5.6.45-2.el6.x86_64.rpm: [Errno 14] PYCURL ERROR 52 - "Empty reply from server"
Trying other mirror.
(3/5): mysql-community-libs-5.6.45-2.el6.x86_64.rpm           | 1.9 MB     00:02     
(4/5): mysql-community-server-5.6.45-2.el6.x86_64.rpm         |  55 MB     01:48     
(5/5): perl-DBI-1.609-4.el6.x86_64.rpm                        | 705 kB     00:01     


Error Downloading Packages:
  mysql-community-common-5.6.45-2.el6.x86_64: failure: mysql-community-common-5.6.45-2.el6.x86_64.rpm from mysql56-community: [Errno 256] No more mirrors to try.

通过百度翻译原来是下载出了问题。此时检查下linux虚拟机是否联网,可以打开百度搜搜东西,同时在再次执行第五步下载。

正在下载包:

(1/5):mysql-community-client-5.6.45-2.el6.x86_.rpm 18 MB 00:32

http://repo.mysql.com/yum/mysql-5.6-community/el/6/x86_64/mysql-community-common-5.6.45-2.el6.x86_64.rpm:[errno 14]pycurl错误52-“从服务器空回复”

尝试其他镜像。

(3/5):mysql-community-libs-5.6.45-2.el6.x86_.rpm 1.9 MB 00:02

(4/5):mysql-community-server-5.6.45-2.el6.x86_.rpm_55 MB 01:48

(5/5):perl-dbi-1.609-4.el6.x86_.rpm_705 kb 00:01




下载包时出错:

mysql-community-common-5.6.45-2.el6.x86_64:失败:mysql-community-common-5.6.45-2.el6.x86_64.rpm来自mysql56 community:[errno 256]没有更多镜像可供尝试。

这里是执行的第五步代码,看见Complete!执行成功。

[root@localhost bin]# yum install mysql-community-server
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirror.jdcloud.com
 * extras: mirror.jdcloud.com
 * updates: mirror.jdcloud.com
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.6.45-2.el6 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.6.45-2.el6 for package: mysql-community-server-5.6.45-2.el6.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.6.10 for package: mysql-community-server-5.6.45-2.el6.x86_64
--> Processing Dependency: perl(DBI) for package: mysql-community-server-5.6.45-2.el6.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.6.45-2.el6 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.6.10 for package: mysql-community-client-5.6.45-2.el6.x86_64
---> Package mysql-community-common.x86_64 0:5.6.45-2.el6 will be installed
---> Package perl-DBI.x86_64 0:1.609-4.el6 will be installed
--> Running transaction check
---> Package mysql-community-libs.x86_64 0:5.6.45-2.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================
 Package                        Arch           Version              Repository                 Size
====================================================================================================
Installing:
 mysql-community-server         x86_64         5.6.45-2.el6         mysql56-community          55 M
Installing for dependencies:
 mysql-community-client         x86_64         5.6.45-2.el6         mysql56-community          18 M
 mysql-community-common         x86_64         5.6.45-2.el6         mysql56-community         309 k
 mysql-community-libs           x86_64         5.6.45-2.el6         mysql56-community         1.9 M
 perl-DBI                       x86_64         1.609-4.el6          base                      705 k

Transaction Summary
====================================================================================================
Install       5 Package(s)

Total size: 76 M
Total download size: 309 k
Installed size: 338 M
Is this ok [y/N]: y
Downloading Packages:
mysql-community-common-5.6.45-2.el6.x86_64.rpm                               | 309 kB     00:00     
warning: rpmts_HdrFromFdno: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Retrieving key from file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
 Userid : MySQL Release Engineering <mysql-build@oss.oracle.com>
 Package: mysql-community-release-el6-5.noarch (installed)
 From   : file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]: y
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
 Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>
 Package: centos-release-6-7.el6.centos.12.3.x86_64 (@anaconda-CentOS-201508042137.x86_64/6.7)
 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : mysql-community-common-5.6.45-2.el6.x86_64                                       1/5 
  Installing : mysql-community-libs-5.6.45-2.el6.x86_64                                         2/5 
  Installing : mysql-community-client-5.6.45-2.el6.x86_64                                       3/5 
  Installing : perl-DBI-1.609-4.el6.x86_64                                                      4/5 
  Installing : mysql-community-server-5.6.45-2.el6.x86_64                                       5/5 
  Verifying  : mysql-community-client-5.6.45-2.el6.x86_64                                       1/5 
  Verifying  : mysql-community-libs-5.6.45-2.el6.x86_64                                         2/5 
  Verifying  : mysql-community-common-5.6.45-2.el6.x86_64                                       3/5 
  Verifying  : mysql-community-server-5.6.45-2.el6.x86_64                                       4/5 
  Verifying  : perl-DBI-1.609-4.el6.x86_64                                                      5/5 

Installed:
  mysql-community-server.x86_64 0:5.6.45-2.el6                                                      

Dependency Installed:
  mysql-community-client.x86_64 0:5.6.45-2.el6     mysql-community-common.x86_64 0:5.6.45-2.el6    
  mysql-community-libs.x86_64 0:5.6.45-2.el6       perl-DBI.x86_64 0:1.609-4.el6                   

Complete!

执行第六步:

service mysqld start
Initializing MySQL database:  2019-09-02 09:53:38 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-09-02 09:53:38 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2019-09-02 09:53:38 0 [Note] /usr/sbin/mysqld (mysqld 5.6.45) starting as process 3587 ...
2019-09-02 09:53:38 3587 [Note] InnoDB: Using atomics to ref count buffer pool pages
2019-09-02 09:53:38 3587 [Note] InnoDB: The InnoDB memory heap is disabled
2019-09-02 09:53:38 3587 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-09-02 09:53:38 3587 [Note] InnoDB: Memory barrier is not used
2019-09-02 09:53:38 3587 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-09-02 09:53:38 3587 [Note] InnoDB: Using Linux native AIO
2019-09-02 09:53:38 3587 [Note] InnoDB: Using CPU crc32 instructions
2019-09-02 09:53:38 3587 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2019-09-02 09:53:39 3587 [Note] InnoDB: Completed initialization of buffer pool
2019-09-02 09:53:39 3587 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2019-09-02 09:53:39 3587 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2019-09-02 09:53:39 3587 [Note] InnoDB: Database physically writes the file full: wait...
2019-09-02 09:53:39 3587 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2019-09-02 09:53:39 3587 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2019-09-02 09:53:39 3587 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2019-09-02 09:53:39 3587 [Warning] InnoDB: New log files created, LSN=45781
2019-09-02 09:53:39 3587 [Note] InnoDB: Doublewrite buffer not found: creating new
2019-09-02 09:53:39 3587 [Note] InnoDB: Doublewrite buffer created
2019-09-02 09:53:39 3587 [Note] InnoDB: 128 rollback segment(s) are active.
2019-09-02 09:53:39 3587 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-09-02 09:53:39 3587 [Note] InnoDB: Foreign key constraint system tables created
2019-09-02 09:53:39 3587 [Note] InnoDB: Creating tablespace and datafile system tables.
2019-09-02 09:53:39 3587 [Note] InnoDB: Tablespace and datafile system tables created.
2019-09-02 09:53:39 3587 [Note] InnoDB: Waiting for purge to start
2019-09-02 09:53:39 3587 [Note] InnoDB: 5.6.45 started; log sequence number 0
2019-09-02 09:53:40 3587 [Note] Binlog end
2019-09-02 09:53:40 3587 [Note] InnoDB: FTS optimize thread exiting.
2019-09-02 09:53:40 3587 [Note] InnoDB: Starting shutdown...
2019-09-02 09:53:41 3587 [Note] InnoDB: Shutdown completed; log sequence number 1625977


2019-09-02 09:53:41 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-09-02 09:53:41 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2019-09-02 09:53:41 0 [Note] /usr/sbin/mysqld (mysqld 5.6.45) starting as process 3609 ...
2019-09-02 09:53:41 3609 [Note] InnoDB: Using atomics to ref count buffer pool pages
2019-09-02 09:53:41 3609 [Note] InnoDB: The InnoDB memory heap is disabled
2019-09-02 09:53:41 3609 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-09-02 09:53:41 3609 [Note] InnoDB: Memory barrier is not used
2019-09-02 09:53:41 3609 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-09-02 09:53:41 3609 [Note] InnoDB: Using Linux native AIO
2019-09-02 09:53:41 3609 [Note] InnoDB: Using CPU crc32 instructions
2019-09-02 09:53:41 3609 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2019-09-02 09:53:41 3609 [Note] InnoDB: Completed initialization of buffer pool
2019-09-02 09:53:41 3609 [Note] InnoDB: Highest supported file format is Barracuda.
2019-09-02 09:53:41 3609 [Note] InnoDB: 128 rollback segment(s) are active.
2019-09-02 09:53:41 3609 [Note] InnoDB: Waiting for purge to start
2019-09-02 09:53:41 3609 [Note] InnoDB: 5.6.45 started; log sequence number 1625977
2019-09-02 09:53:41 3609 [Note] Binlog end
2019-09-02 09:53:41 3609 [Note] InnoDB: FTS optimize thread exiting.
2019-09-02 09:53:41 3609 [Note] InnoDB: Starting shutdown...
2019-09-02 09:53:43 3609 [Note] InnoDB: Shutdown completed; log sequence number 1625987




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 localhost.localdomain 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/

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

Note: new default config file not created.
Please make sure your config file is current

WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server

                                                           [  OK  ]
Starting mysqld:                                           [  OK  ]

怕不对,又执行第六步了一遍。

 bin]# service mysqld start
Starting mysqld:                                           [  OK  ]

稍微吐槽一下:就着一个问题,弄了两天,原来是linux待机时间长,网不好的问题导致的(猜测哈,因为实验次数不多)。

### 解决 `mysqld: unrecognized service` 错误 当执行命令 `sudo service mysqld start` 后收到错误提示 `mysqld: unrecognized service`,这表明系统未能找到名为 `mysqld` 的服务。此问题可能由多种因素引起,包括但不限于安装路径配置不正确、服务名称差异或是初始化脚本缺失。 #### 验证 MySQL 安装状态 确认 MySQL 是否已成功安装以及其版本信息至关重要。可以利用以下命令来验证: ```bash dpkg -l | grep mysql ``` 如果上述命令未返回任何有关 MySQL 或 MariaDB 的条目,则说明软件包尚未被正确部署到操作系统中[^1]。 #### 检查并修正服务名 不同 Linux 发行版服务管理工具对于 MySQL 服务有不同的命名约定。例如,在某些环境中应使用 `mysql` 而不是 `mysqld` 来指代该服务。因此建议先尝试更改为标准的服务调用方式: ```bash sudo systemctl start mysql.service # 或者 sudo service mysql start ``` 若以上两种方法均能正常工作,则证明原问题是由于采用了不当的服务标识符所造成的[^2]。 #### 更新 SysV Init Script 或 Systemd Unit File 对于基于 Red Hat/CentOS 的发行版,默认情况下可能会依赖于较旧的 SysV init script;而对于 Debian/Ubuntu 类型的操作系统则更多采用 systemd unit file 进行进程控制。确保对应类型的启动文件存在且无语法错误非常重要。可以通过下面的方式创建或修复这些必要的配置文档: 针对 SysV init 用户: - 创建 `/etc/init.d/mysql` 文件,并赋予可执行权限; - 使用 chkconfig 工具注册新加入的服务定义。 面向 systemd 用户: - 编辑位于 `/lib/systemd/system/mysqld.service` 中的内容以匹配实际环境需求; - 执行 `systemctl daemon-reload` 命令刷新内部缓存以便应用更改后的设置[^3]。 #### 排除其他潜在障碍 除了调整服务名称外,还需注意是否存在 SELinux 等安全模块阻止了正常的访问请求。临时禁用此类防护措施可以帮助判断它们是否为当前状况的根本原因所在。另外,查阅日志记录也是不可或缺的一环——特别是查看 `/var/log/messages` `/var/lib/mysql/*.err` 下的相关警告消息能够提供更多线索用于进一步诊断分析[^4]。 通过采取上述措施之一或多步组合操作,应该可以有效克服 `mysqld: unrecognized service` 的困扰,使 MySQL 数据库得以顺利运行起来。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值