我在RHEL中使用rpm包安装了MySQL5.7.19,我的要求是使用mysqld初始化数据目录,使用其他用户'SAM‘而不是mysql用户来初始化MySQL服务器。我创建了my.cnf文件并创建了一个符号链接i -s etc/my.cnf .my.cnf,下面是my.cnf的内容
[client] port=3307 socket=/tmp/mysql.sock host=localhost default-character-set=utf8[mysqld]
port=3307
socket=/tmp/mysql.sock
datadir=/home/data/db
log-error=/var/opt/mysql/mysql-error.log
sql-mode=""
default-storage-engine=MyISAM
long_query_time=5
max_allowed_packet=16M
# Accept 4.0.x style passwords
# old-passwords=ON
character_set_server=utf8
[mysqldump]
quick运行命令时,我在文件中获得以下日志( mysql -error.log),而mysql服务器没有启动mysqld --缺省值-file=/home/etc/my.cnf-basedir=/usr/sbin/.-pid-file=/var/opt/mysql/mysql.pid
18-06-06T05:02:31.933483Z 0 [Note] InnoDB: Foreign key constraint system tables created
2018-06-06T05:02:31.933518Z 0 [Note] InnoDB: Creating tablespace and datafile system tables.
2018-06-06T05:02:31.935391Z 0 [Note] InnoDB: Tablespace and datafile system tables created.
2018-06-06T05:02:31.935417Z 0 [Note] InnoDB: Creating sys_virtual system tables.
2018-06-06T05:02:31.936921Z 0 [Note] InnoDB: sys_virtual table created
2018-06-06T05:02:31.937905Z 0 [Note] InnoDB: 5.7.19 started; log sequence number 0
2018-06-06T05:02:31.938825Z 0 [Note] Plugin 'FEDERATED' is disabled.
mysqld: Table 'mysql.plugin' doesn't exist
2018-06-06T05:02:31.938932Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2018-06-06T05:02:31.939424Z 0 [Note] Salting uuid generator variables, current_pid: 12598, server_start_time: 1528261351, bytes_sent: 0,
2018-06-06T05:02:31.939459Z 0 [Note] Generated uuid: 'd1916718-6946-11e8-9f90-000c29429204', server_start_time: 3546021758129118237, bytes_sent: 50645584
2018-06-06T05:02:31.939475Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: d1916718-6946-11e8-9f90-000c29429204.
2018-06-06T05:02:31.941093Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-06-06T05:02:31.941184Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
2018-06-06T05:02:31.941191Z 0 [Note] Server hostname (bind-address): '*'; port: 3307
2018-06-06T05:02:31.941207Z 0 [Note] IPv6 is available.
2018-06-06T05:02:31.941211Z 0 [Note] - '::' resolves to '::';
2018-06-06T05:02:31.941258Z 0 [Note] Server socket created on IP: '::'.
2018-06-06T05:02:31.942764Z 0 [Warning] Failed to open optimizer cost constant tables
2018-06-06T05:02:31.942851Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
2018-06-06T05:02:31.942892Z 0 [ERROR] Aborting请有人回答是否可以使用其他用户而不是mysql来初始化mysql服务器?
注意:这是一个新的安装,而不是升级。(这一事实是从现在删除的答案中复制的。)
发布于 2018-06-06 08:38:20
在网站这里中,您只需修改这一行
shell> bin/mysqld --initialize --user=mysql并将其改为:
shell> bin/mysqld --initialize --user=other_username这个用户(不是数据库服务器意义上的用户,而是操作系统(OS)意义上的用户)只确定底层文件系统的权限--例如,谁拥有数据-dir,它与MySQL数据库用户无关。为了清晰起见,我会为OS用户和MySQL用户使用不同的名称。
通过编译源代码,您可以获得对系统的更细粒度的控制,但是如果您只想更改底层OS文件系统上文件的所有者,那么就这样做吧!
您可以使用-初始化-不安全,然后以root用户身份登录并立即更改密码,在没有密码的情况下以root身份登录:
shell >mysql --user=root和然后
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
mysql> flush privileges;退出,然后用
shell >mysql -u root -p在-p之后,键入任何其他内容,然后按Return。然后应该提示您输入刚才输入的密码(MyNewPass)。
https://dba.stackexchange.com/questions/208858
复制相似问题