我已经在 RedHat 6(64 位)机器上安装了 mysql 5.7(解压了压缩的二进制文件),但我没有 root 访问权限。
我正在关注这教程启动 SQL 服务器并初始化数据库,但我收到错误。解决方案发布这里也会出现错误,建议不要mysql_install_db
再使用,因为它已被弃用。
我目前所做的:我已将二进制文件解压到目录中/home/username/mysql/
(存储在变量中$MYSQL_HOME
),并在其中创建了一个data/
和log/
文件夹。我还创建了两个文件my.ini
和my.cnf
我的cnf
[mysqld]
user=mysqluser
我的配置文件
export BASE_DIR=$MYSQL_HOME
export DATADIR=$BASE_DIR/data
从$MYSQL_HOME/mysql-install-folder/bin
我跑
./mysqld --user=mysqluser
--datadir=$DATADIR
--basedir=$MYSQL_HOME
--log-error=$MYSQL_HOME/log/mysql.err
--pid-file=$MYSQL_HOME/mysql.pid
--socket=$MYSQL_HOME/socket
--port=3306
--initialize
但是我得到了这个错误
323$ ./mysqld --user=quad --datadir=$DATADIR --basedir=$MYSQL_HOME --log-error=$MYSQL_HOME/log/mysql.err --pid-file=$MYSQL_HOME/mysql.pid --socket=$MYSQL_HOME/socket --port=3306 --initialize
2018-03-26T18:12:22.795302Z 0 [Warning] Ignoring user change to 'mysqluser' because the user was set to 'mysql' earlier on the command line
2018-03-26T18:12:22.795338Z 0 [Warning] Ignoring user change to 'mysqluser' because the user was set to 'mysql' earlier on the command line
2018-03-26T18:12:22.795352Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-03-26T18:12:22.795410Z 0 [ERROR] Can't find error-message file '/home/username/mysql/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
2018-03-26T18:12:22.797158Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2018-03-26T18:12:22.797183Z 0 [ERROR] Aborting
首先,我不明白为什么它不覆盖用户名mysql
,然后有关错误消息文件的错误对我来说很神秘。
编辑
我按照说明这里,现在我有这个配置文件/home/username/mysql
:
我的cnf
[mysqld]
port=3306
socket=[Base MySQL Directory]/thesock
basedir=[Base MySQL Directory]
datadir=[Base MySQL Directory]/data
log-error=[Base MySQL Directory]/data/mysql.err
pid-file=[Base MySQL Directory]/mysql.pid
user=username
[client]
port=3306
socket=[Base MySQL Directory]/thesock
user=username
[mysqladmin]
socket=[Base MySQL Directory]/thesock
user=username
当我使用
./mysqld --defaults-file=$MYSQL_HOME/my.cnf&
它显示了我猜测的进程 ID
[2] 2281405
但是当我尝试启动客户端时
./mysql --defaults-file=/home/SHD_xnqu/mysql/my.cnf
它会抛出错误
ERROR 1045 (28000): Unknown error 1045
谢谢您的帮助