mysql编译安装时常见错误分析_MySQL编译安装时常见错误分析

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=

This CMake script will look for boost in . 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".

解决方法:先下载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_start_error.png

解决方法:主要通过命令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/。

备注:这个问题,网上这个兄弟并没有完全解决,但是说对一点,确实是目录权限的问题,是安装目录需要设置chown -R mysql:mysql /usr/local/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='your password';

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='your password' where User='root';

mysql> SET PASSWORD for root@'localhost' = PASSWORD('your password');

mysql> SET PASSWORD = PASSWORD('your password');

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值