Home Database Mysql Tutorial mysql启动提示mysql.host 不存在,启动失败的解决方法_MySQL

mysql启动提示mysql.host 不存在,启动失败的解决方法_MySQL

Jun 01, 2016 pm 01:22 PM
error mysql Record

bitsCN.com error 日志当中的记录:

[ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist

从发了帖子,只有人看,没有人回复,看到这种情况只能自己解决问题了,自己动手丰衣足食吗, 嗯。。。 你还别说,还真让我解决了问题,人啊,都是逼出来的,....没有办法,这个问题对于高手可能是很简单的问题 ,但是对我第一次摸mysql,确实怎么也弄不懂的问题。
好了闲话不多说 说一下我解决的过程:

按照mysql的安装步骤:
shell> groupadd mysql
shell> useradd -g mysql mysql
shell> gunzip shell> cd mysql-VERSION
shell> ./configure --prefix=/usr/local/mysql
shell> make
shell> make install
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root /usr/local/mysql
shell> chown -R mysql /usr/local/mysql/var
shell> chgrp -R mysql /usr/local/mysql
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> /usr/local/mysql/bin/mysqld_safe --user=mysql &

这样标准进行下来是没有问题的,但在最后一步启动mysql的时候我希望将数据库的数据文件放在另外一个目录下面,启动命令修改为:
shell>/usr/local/mysql/bin/mysqld_safe --user=mysql --log-error=/u01/mysql/mysql_error/error --datadir=/u01/mysql/data

这个时候就出现问题了, 因为在进行初始化数据库权限表的那一步的时候默认创建的权限表在默认目录/usr/local/mysql/var下面,这就造成了,上面的错误无法找到 权限表:Can't open and lock privilege tables: Table 'mysql.host' doesn't exist

解决办法 在运行初始化权限表的时候使用增加参数--datadir ,命令格式为:
shell> scripts/mysql_install_db --user=mysql --datadir=/u01/mysql/data
这样问题就解决了。
这样问题同样也会出现 你将自己的数据库的数据文件修改为别的目录的时候,因为你没有在相应的目录下创建数据库权限表,解决办法就是你重新运行mysql_install_db 文件,重新生成数据库权限表,但是相应的你也要重新建里用户,以及设置权限; 第二个办法应该将老的权限表的文件拷贝倒相应数据库表对应的目录先即可,但是第二个办法我没有用过只是根据自己的想象猜的。如果有高手请给确认一下是否正确

MySQL 提示服务启动失败的解决办法

以前经常碰到这个问题,但都是用以下办法处理的,

先在添加删除程序里卸载MySQL,然后把原MySQL的目录改名,再打开注册表用F3循环查找“MySQL”,全部删除,最后重启机器再重新装MySQL都可以搞定,但今天遇到的问题比特殊,按上面和下面的办法全试过了依然不行,安装到最后一到启动那里就失败了,把所有正在运行的服务和软件全部关掉,又连续重启重装了N次都是到那里停止,后来干脆换个高版本儿试下,这次全部删除后重装到最后那一步时还是等了很长时间,最后竟然成功了,现在记录下来,以后再遇到此类问题不用再郁闷了!

重装是成功了,但是重启后测试发现又出问题了,服务启动不了,一直报错如下:
在 本地计算机 无法启动 MySQL 服务。
错误 1053: 服务没有及时响应启动或控制请求。

又研究了半天,最后终于搞定,发现他原来的计算机管理员用户名里有个$字符,心想不会是他的事儿吧,就建了一个正常的独立计算机账户MySQLUSER,然后在进程里把mysqld.exe结束,然后在MySQL所在的目录上点右键属性安全,添加MySQLUSER这个用户并给完全控制权限,再打开服务管理器在MySQL服务上点右键,输入刚才建立的账号和密码确定,如下图!
mysql启动提示mysql.host 不存在,启动失败的解决方法_MySQL
最后再随意重启服务,重启计算机再试,依然很顺利,至此这个疑难问题算是彻底解决,问题根源就是那个系统管理员账号内的$字符,呵呵。

附几个常用的MySQL的下载地址和MySQL管理工具!

http://sys.7i24.com/soft/mysql5132.rar
http://sys.7i24.com/soft/mysql5158.rar
http://mysql.he.net/Downloads/MySQL-5.5/mysql-5.5.21-win32.msi

MySQL 5.5.12 官方版(For Windows 64位)
thunder://QUFodHRwOi8veGlhemFpLnhpYXphaWJhLmNvbS9Tb2Z0L00vTXlTUUxfNS41LjEyX3dpbng2NF9YaWFaYWlCYS56aXBaWg==

● Navicat for MySQL V9.0.15 绿色中文版_优秀的数据库管理和开发工具
thunder://QUFodHRwOi8vd3d3dy4xMTkueGRvd25zLmNvbS91cGxvYWRGaWxlLzIwMTAtMTAvbmF2aWNhdF9mb3JfTXlTUUwucmFyWlo=


================以下是遇到此类问题时的常规处理办法========================
mysql 安装到最后一步时,start service 为失败状态 请问是什么原因

使用services.msc打

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP's big data structure processing skills PHP's big data structure processing skills May 08, 2024 am 10:24 AM

Big data structure processing skills: Chunking: Break down the data set and process it in chunks to reduce memory consumption. Generator: Generate data items one by one without loading the entire data set, suitable for unlimited data sets. Streaming: Read files or query results line by line, suitable for large files or remote data. External storage: For very large data sets, store the data in a database or NoSQL.

How to use MySQL backup and restore in PHP? How to use MySQL backup and restore in PHP? Jun 03, 2024 pm 12:19 PM

Backing up and restoring a MySQL database in PHP can be achieved by following these steps: Back up the database: Use the mysqldump command to dump the database into a SQL file. Restore database: Use the mysql command to restore the database from SQL files.

How to optimize MySQL query performance in PHP? How to optimize MySQL query performance in PHP? Jun 03, 2024 pm 08:11 PM

MySQL query performance can be optimized by building indexes that reduce lookup time from linear complexity to logarithmic complexity. Use PreparedStatements to prevent SQL injection and improve query performance. Limit query results and reduce the amount of data processed by the server. Optimize join queries, including using appropriate join types, creating indexes, and considering using subqueries. Analyze queries to identify bottlenecks; use caching to reduce database load; optimize PHP code to minimize overhead.

How to insert data into a MySQL table using PHP? How to insert data into a MySQL table using PHP? Jun 02, 2024 pm 02:26 PM

How to insert data into MySQL table? Connect to the database: Use mysqli to establish a connection to the database. Prepare the SQL query: Write an INSERT statement to specify the columns and values ​​to be inserted. Execute query: Use the query() method to execute the insertion query. If successful, a confirmation message will be output.

How to use MySQL stored procedures in PHP? How to use MySQL stored procedures in PHP? Jun 02, 2024 pm 02:13 PM

To use MySQL stored procedures in PHP: Use PDO or the MySQLi extension to connect to a MySQL database. Prepare the statement to call the stored procedure. Execute the stored procedure. Process the result set (if the stored procedure returns results). Close the database connection.

How to create a MySQL table using PHP? How to create a MySQL table using PHP? Jun 04, 2024 pm 01:57 PM

Creating a MySQL table using PHP requires the following steps: Connect to the database. Create the database if it does not exist. Select a database. Create table. Execute the query. Close the connection.

How to fix mysql_native_password not loaded errors on MySQL 8.4 How to fix mysql_native_password not loaded errors on MySQL 8.4 Dec 09, 2024 am 11:42 AM

One of the major changes introduced in MySQL 8.4 (the latest LTS release as of 2024) is that the "MySQL Native Password" plugin is no longer enabled by default. Further, MySQL 9.0 removes this plugin completely. This change affects PHP and other app

The difference between oracle database and mysql The difference between oracle database and mysql May 10, 2024 am 01:54 AM

Oracle database and MySQL are both databases based on the relational model, but Oracle is superior in terms of compatibility, scalability, data types and security; while MySQL focuses on speed and flexibility and is more suitable for small to medium-sized data sets. . ① Oracle provides a wide range of data types, ② provides advanced security features, ③ is suitable for enterprise-level applications; ① MySQL supports NoSQL data types, ② has fewer security measures, and ③ is suitable for small to medium-sized applications.

See all articles