我在 *nix 机器上工作并且没有root
权限。
我正在尝试使用以下博文在本地安装 mysql:http://www.thedance.net/~roth/TECHBLOG/localMySQL.html
然而,我却被困在scripts/mysql_install_db
命令中。
当我运行此命令时出现以下错误:
FATAL ERROR: Neither host 'server.address.com' nor 'localhost' could be looked up with
/usr/bin/resolveip
Please configure the 'hostname' command to return a correct hostname.
If you want to solve this at a later stage, restart this script
with the --force option
经过进一步挖掘,我发现添加--basedir
可以解决这个问题。但随后会产生以下错误:
$scripts/mysql_install_db --basedir=.
Installing MySQL system tables...2015-07-17 01:38:15 0 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
2015-07-17 01:38:15 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-07-17 01:38:15 0 [Note] ./bin/mysqld (mysqld 5.6.25) starting as process 10281 ...
2015-07-17 01:38:15 10281 [ERROR] Can't find messagefile '/usr/share/mysql/errmsg.sys'
2015-07-17 01:38:15 10281 [Warning] Can't create test file /var/lib/mysql/head.lower-test
2015-07-17 01:38:15 10281 [Warning] Can't create test file /var/lib/mysql/head.lower-test
./bin/mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 13 - Permission denied)
2015-07-17 01:38:15 10281 [ERROR] Aborting
2015-07-17 01:38:15 10281 [Note] Binlog end
2015-07-17 01:38:15 10281 [Note]
当我添加--datadir=myDataDir
(其中 myDataDir 是本地目录)时,它会生成以下错误:
$scripts/mysql_install_db --basedir=. --datadir=myDataDir
Installing MySQL system tables...2015-07-17 01:40:54 0 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
2015-07-17 01:40:54 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-07-17 01:40:54 0 [Note] ./bin/mysqld (mysqld 5.6.25) starting as process 10329 ...
2015-07-17 01:40:54 10329 [ERROR] Can't find messagefile '/usr/share/mysql/errmsg.sys'
它正在尝试访问系统级文件夹,但由于权限问题,它失败了。我如何在本地安装它。我如何设置主机名?
答案1
查找my.cnf
可能包含以下行的配置文件:
lc-messages-dir = /usr/share/mysql
正如您所说,由于您当前的权限,mysql 无法访问此标准配置文件。
两种可能的解决方案:
将此参数更改为可访问的目录,并将配置文件传递给 mysql_install_db
$ ./scripts/mysql_install_db --defaults-file=my.cnf --basedir=. --datadir=myDataDir
使用 --no-defaults,以防止从其他配置文件读取
$ ./scripts/mysql_install_db --no-defaults --basedir=. --datadir=myDataDir