<% dim ModuleName,InfoID,ChannelShortName,CorrelativeArticle,InstallDir,ChannelDir,Keyword,PageTitle,ArticleIntro,Articlecontent Keyword=stripHTML("安装,解决方法") PageTitle=stripHTML("MySQL编译安装时常见错误分析") ArticleIntro=stripHTML("MySQL编译安装时常见错误分析,这篇文章主要是关于mysql在编译安装时,可能出现的错误的解决方法。MySQL正确的编译安装操作见前文《2015博客升级记(四):CentOS7.1编译安装MySQL") Articlecontent=stripHTML("
 
  这篇文章主要是关于mysql在编译安装时,可能出现的错误的解决方法。MySQL正确的编译安装操作见前文 《2015博客升级记(四):CentOS 7.…") ModuleName = stripHTML("classical") InfoID = stripHTML("203523") ChannelShortName=stripHTML("文章") InstallDir=stripHTML("http://www.77169.com/") ChannelDir=stripHTML("classical") %> MySQL编译安装时常见错误分析 - 华盟网 - http://www.77169.com
您现在的位置: 华盟网 >> 知识库 >> 数据库 >> Mysql >> 实例技巧 >> 正文

MySQL编译安装时常见错误分析

2015/11/16 作者:不祥 来源: 互联网
导读 <% if len(ArticleIntro)<3 then Response.Write Articlecontent 'Response.Write "Articlecontent" else Response.Write ArticleIntro 'Response.Write "ArticleIntro" end if %>

这篇文章主要是关于mysql在编译安装时,可能出现的错误的解决方法。MySQL正确的编译安装操作见前文 《2015博客升级记(四):CentOS 7.1编译安装MySQL5.7.7rc》 。

1 没有安装MySQL所需要的boost库

测试发现编译MySQL5.7以及更高的版本时,都需要下载并引用或者直接安装boost库,否则在执行 cmake 命令时会报如下错误:

-- Running cmake version 3.2.1 -- Configuring with MAX_INDEXES = 64U -- SIZEOF_VOIDP 8 -- MySQL 5.7.6-m16 [MySQL版本] -- Packaging as: mysql-5.7.6-m16-linux-x86_64 -- Looked for boost/version.hpp in and -- BOOST_INCLUDE_DIR BOOST_INCLUDE_DIR-NOTFOUND -- LOCAL_BOOST_DIR -- LOCAL_BOOST_ZIP -- Could not find (the correct version of) boost. [关键错误信息] -- MySQL currently requires boost_1_57_0 [解决办法] CMake Error at cmake/boost.cmake:76 (MESSAGE): [具体错误和解决方法] You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory> This CMake script will look for boost in <directory>. If it is not there, it will download and unpack it (in that directory) for you. If you are inside a firewall, you may need to use an http proxy: export http_proxy=http://example.com:80 Call Stack (most recent call first): cmake/boost.cmake:228 (COULD_NOT_FIND_BOOST) CMakeLists.txt:452 (INCLUDE) -- Configuring incomplete, errors occurred! See also "/mydata/mysql-5.7.6-m16/CMakeFiles/CMakeOutput.log".

解决方法:直接按照前文 《2015博客升级记(四):CentOS 7.1编译安装MySQL5.7.7rc》 小节2中的方法安装Boost库即可。或者先下载Boost库,然后通过在cmake命令后面添加参数 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=Boost库路径 即可。

2 执行cmake时缺少Ncurses库的支持

Ncurses提供功能键定义(快捷键),屏幕绘制以及基于文本终端的图形互动功能的动态库。

[root@typecodes ~]# yum -y install ncurses-devel -- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH) CMake Error at cmake/readline.cmake:64 (MESSAGE): Curses library not found. Please install appropriate package, remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on redhat and derivates it is ncurses-devel. Call Stack (most recent call first): cmake/readline.cmake:107 (FIND_CURSES) cmake/readline.cmake:181 (MYSQL_USE_BUNDLED_EDITLINE) CMakeLists.txt:480 (MYSQL_CHECK_EDITLINE) -- Configuring incomplete, errors occurred! See also "/mydata/mysql-5.7.6-m16/CMakeFiles/CMakeOutput.log". See also "/mydata/mysql-5.7.6-m16/CMakeFiles/CMakeError.log".

解决方法:直接执行命令 yum -y install ncurses-devel 安装Ncurses即可。

3 安装MySQL完后,无法正常启动服务

在安装完MySQL后,执行命令 service mysqld start 失败,也即无法正常启动MySQL服务。


MySQL编译安装时常见错误分析

解决方法:主要通过命令 systemctl status mysqld.service 和MySQL的日志来分析。如上图所示,在日志文件 /var/log/mysql/error.log 中可以看到具体的 ERROR 信息:Could not create unix socket lock file /var/run/mysql/mysql.sock.lock。这种错误一般都是目录不存在或者权限不足,所以我们直接使用命令 mkdir -p /var/log/mysql/ 创建该目录即可,然后可以设置目录权限 chown -R mysql:mysql /var/log/mysql/ 。

4 操作MySQL时,报错You must SET PASSWORD before executing this statement

用MySQL的root用户登录数据库后,如果之前没有设置密码,那么执行任何操作命令时,会提示如下错误信息。

mysql> CREATE DATABASE `testmysqldatabase` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

常规的使用MySQL安全模式的解决方法如下,但是在MySQL5.7以及更高版本下是行不通的。

[root@typecodes ~]# service mysqld stop Shutting down MySQL..[ OK ] [root@typecodes ~]# /mydata/mysql/bin/mysqld_safe --user=mysql --skip-networking --skip-grant-tables & [1] 3688 [root@typecodes ~]# 150409 23:02:02 mysqld_safe Logging to '/var/log/mysql/error.log'. 150409 23:02:02 mysqld_safe Starting mysqld daemon with databases from /mydata/mysql/data ######重新登录mysql后,设置root密码 mysql> set password='this is a password sample'; ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

有效的解决方法:

[root@typecodes ~]# mysql -u root -p [使用root用户登录] Enter password: [无密码,直接回车] Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.6-m16 Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> select * from mysql.user; ERROR 1820 (HY000): You must SET PASSWORD before executing this statement mysql> set password='this is a password sample'; ERROR 1819 (HY000): Your password does not satisfy the current policy requirements ######设置当前root用户密码 mysql> set password='MYSQLroota7612198981@'; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)

需要说明的是,修改用户密码的SQL语句在不同的MySQL版本中是不同的。下面这3种是MySQL5.5以下的版本的修改方法,但是不适用于MySQL5.7以及更高版本。

mysql> update mysql.user set PASSWORD='MYSQLroota7612198981' where User='root'; mysql> SET PASSWORD for root@'localhost' = PASSWORD('MYSQLroota7612198981'); mysql> SET PASSWORD = PASSWORD('MYSQLroota7612198981');

本文数据库(mysql)相关术语:navicat for mysql mysql workbench mysql数据库 mysql 存储过程 mysql安装图解 mysql教程 mysql 管理工具