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

The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

The process of starting MySQL in Docker consists of the following steps: Pull the MySQL image to create and start the container, set the root user password, and map the port verification connection Create the database and the user grants all permissions to the database

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

I encountered a tricky problem when developing a small application: the need to quickly integrate a lightweight database operation library. After trying multiple libraries, I found that they either have too much functionality or are not very compatible. Eventually, I found minii/db, a simplified version based on Yii2 that solved my problem perfectly.

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA
