Linux中MySQL 无法正常启动的解决
最近在公司做的项目中用到了MySQL数据库,系统版本是CentOS 5.1 i386。在刚安装完时,使用quot;service mysql startquot;无法正
最近在公司做的项目中用到了MySQL数据库,系统版本是CentOS 5.1 i386。
在刚安装完时,使用"service mysql start"无法正常开启。手动运行mysqld_safe程序,错误信息是"...../etc/rc.d/init.d/mysql 159:kill(xxxx) no such process"。在网上搜了一下,很多人都解决了,但是没有见到详细的讲解和错误原因的分析。我又看了一下MySQL的说明文档,发现了问题所在。此错误信息,说明mysqld_safe程序启动失败---虽然显示的是无法kill某进程,此处的kill只是为了测试指定进程是否仍然存在。
当出现错误时,你需要检查以下内容:
1、selinux是否已经关闭。
2、如果使用默认的方式安装,查看用户"mysql"是否已创建。
3、mysql配置信息中的datadir目录是否已经创建(使用此命令查看已配置的datadir:mysqld --verbose --help | grep datadir)。
4、datadir目录的所有者,是否和mysqld_safe命令行选项中的相同(默认为"mysql"用户)。
错误原因分析:
1、在使用RPM包安装完MySQL-server-xxxx.rpm之后,会看到终端中显示了上面提到的错误,MySQL开启失败。此时造成开启失败的原因,很有可能是开启了selinux,关闭selinux(具体方法请google一下),重启系统,,一般情况下,问题可以解决。刚才已在我的虚拟机中重新尝试了一次。
2、使用rpm包进行安装时,会自动创建"mysql"用户,但是在某些“可信的操作系统”中,root用户无权添加新用户,会导致错误。此时你可以使用具有添加新用户权限的用户,手动添加"mysql"帐户,密码随意设置。当你只能使用root用户时,可以在my.cnf(下面会介绍此文件)中做如下修改:
[mysqld]
user = root #或者是其他可使用的用户名称
此处的"root"即为脚本中调用mysqld_safe程序时,命令行中指定的系统用户。
3、安装MySQL-server-xxxx.rpm之后,显示正常开启,但是修改了my.cnf(原文件为/usr/share/mysql/中的my-xxxx.cnf文件,需要选择合适的文件复制到/etc/目录中,并且改名为my.cnf)文件之后,出现错误。此时错误的原因,很有可能是因为你没有调用mysql_install_db函数,此函数负责创建mysql的基本数据库,如登录用户的信息等,以及使用my.cnf对mysql进行配置,如数据库目录(datadir),根目录(basedir)等。在当前系统中,默认datadir为/var/lib/mysql/。
4、使用rpm包安装时,mysql_install_db函数被默认的调用,但是配置信息也是默认的。当你改写了my.cnf文件之后,需要重新调用"mysql_install_db --user=mysql"命令,以按照新的配置文件对数据库进行配置。其中的"--user=mysql"选项,使创建的datadir的创建者和所有者为mysql用户(使用rpm包安装时,自动创建此用户)。如果没有为mysqld_safe指定其他用户,必须添加此选项。
参考以上的方法,MySQL无法正常启动的问题应该能够解决。对于CentOS 5.1以外的系统,没有进行测试。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Improve HDFS performance on CentOS: A comprehensive optimization guide to optimize HDFS (Hadoop distributed file system) on CentOS requires comprehensive consideration of hardware, system configuration and network settings. This article provides a series of optimization strategies to help you improve HDFS performance. 1. Hardware upgrade and selection resource expansion: Increase the CPU, memory and storage capacity of the server as much as possible. High-performance hardware: adopts high-performance network cards and switches to improve network throughput. 2. System configuration fine-tuning kernel parameter adjustment: Modify /etc/sysctl.conf file to optimize kernel parameters such as TCP connection number, file handle number and memory management. For example, adjust TCP connection status and buffer size

CentOS will be shut down in 2024 because its upstream distribution, RHEL 8, has been shut down. This shutdown will affect the CentOS 8 system, preventing it from continuing to receive updates. Users should plan for migration, and recommended options include CentOS Stream, AlmaLinux, and Rocky Linux to keep the system safe and stable.

Complete Guide to Checking HDFS Configuration in CentOS Systems This article will guide you how to effectively check the configuration and running status of HDFS on CentOS systems. The following steps will help you fully understand the setup and operation of HDFS. Verify Hadoop environment variable: First, make sure the Hadoop environment variable is set correctly. In the terminal, execute the following command to verify that Hadoop is installed and configured correctly: hadoopversion Check HDFS configuration file: The core configuration file of HDFS is located in the /etc/hadoop/conf/ directory, where core-site.xml and hdfs-site.xml are crucial. use

The CentOS shutdown command is shutdown, and the syntax is shutdown [Options] Time [Information]. Options include: -h Stop the system immediately; -P Turn off the power after shutdown; -r restart; -t Waiting time. Times can be specified as immediate (now), minutes ( minutes), or a specific time (hh:mm). Added information can be displayed in system messages.

The Installation, Configuration and Optimization Guide for HDFS File System under CentOS System This article will guide you how to install, configure and optimize Hadoop Distributed File System (HDFS) on CentOS System. HDFS installation and configuration Java environment installation: First, make sure that the appropriate Java environment is installed. Edit /etc/profile file, add the following, and replace /usr/lib/java-1.8.0/jdk1.8.0_144 with your actual Java installation path: exportJAVA_HOME=/usr/lib/java-1.8.0/jdk1.8.0_144exportPATH=$J

When configuring Hadoop Distributed File System (HDFS) on CentOS, the following key configuration files need to be modified: core-site.xml: fs.defaultFS: Specifies the default file system address of HDFS, such as hdfs://localhost:9000. hadoop.tmp.dir: Specifies the storage directory for Hadoop temporary files. hadoop.proxyuser.root.hosts and hadoop.proxyuser.ro

The key differences between CentOS and Ubuntu are: origin (CentOS originates from Red Hat, for enterprises; Ubuntu originates from Debian, for individuals), package management (CentOS uses yum, focusing on stability; Ubuntu uses apt, for high update frequency), support cycle (CentOS provides 10 years of support, Ubuntu provides 5 years of LTS support), community support (CentOS focuses on stability, Ubuntu provides a wide range of tutorials and documents), uses (CentOS is biased towards servers, Ubuntu is suitable for servers and desktops), other differences include installation simplicity (CentOS is thin)

Installing MySQL on CentOS involves the following steps: Adding the appropriate MySQL yum source. Execute the yum install mysql-server command to install the MySQL server. Use the mysql_secure_installation command to make security settings, such as setting the root user password. Customize the MySQL configuration file as needed. Tune MySQL parameters and optimize databases for performance.
