背景
mariadb在docker中运行,采用yum安装mariadb server的形式,然后使用mysql_install_db初始化的时指定my.cnf路径
环境
- centos 7.4
- mariadb 10.1.38
问题
[root@test /]# mysql_install_db --defaults-file=/etc/my.cnf --user=mysql
Neither host 'test' nor 'localhost' could be looked up with
'/usr/sbin/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
The latest information about mysql_install_db is available at
https://mariadb.com/kb/en/installing-system-tables-mysql_install_db
[root@test /]# cat /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.3 test
[root@test /]# mysql_install_db --defaults-file=/etc/my.cnf --user=mysql --datadir=/var/lib/mysql/data/mydata/
Neither host 'test' nor 'localhost' could be looked up with
'/usr/sbin/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
The latest information about mysql_install_db is available at
https://mariadb.com/kb/en/installing-system-tables-mysql_install_db
[root@test /]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.3 test
[root@test /]# mysql_install_db --defaults-file=/etc/my.cnf --user=mysql
Neither host 'test' nor 'localhost' could be looked up with
'/usr/sbin/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
The latest information about mysql_install_db is available at
https://mariadb.com/kb/en/installing-system-tables-mysql_install_db
[root@test /]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.3 test
解决方式
[root@test /]# mysql_install_db --defaults-file=/etc/my.cnf --user=mysql --force
Installing MariaDB/MySQL system tables in '/var/lib/mysql/data/mydata' ...
2019-02-15 12:57:08 140419367405824 [Warning] 'table-open-cache-instances' is MySQL 5.6 compatible option. Not used or needed in MariaDB.
2019-02-15 12:57:08 140419367405824 [Note] /usr/sbin/mysqld (mysqld 10.1.38-MariaDB) starting as process 610 ...
OK
Filling help tables...
2019-02-15 12:57:58 140283421616384 [Warning] 'table-open-cache-instances' is MySQL 5.6 compatible option. Not used or needed in MariaDB.
2019-02-15 12:57:58 140283421616384 [Note] /usr/sbin/mysqld (mysqld 10.1.38-MariaDB) starting as process 659 ...
OK
Creating OpenGIS required SP-s...
2019-02-15 12:58:04 140430938585344 [Warning] 'table-open-cache-instances' is MySQL 5.6 compatible option. Not used or needed in MariaDB.
2019-02-15 12:58:04 140430938585344 [Note] /usr/sbin/mysqld (mysqld 10.1.38-MariaDB) starting as process 710 ...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:
'/usr/sbin/mysqladmin' -u root password 'new-password'
'/usr/sbin/mysqladmin' -u root -h password 'new-password'
Alternatively you can run:
'/usr/sbin/mysql_secure_installation'
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.
You can start the MariaDB daemon with:
cd '/usr' ; /usr/sbin/mysqld_safe --datadir='/var/lib/mysql/data/mydata'
You can test the MariaDB daemon with mysql-test-run.pl
cd '/usr/mysql-test' ; perl mysql-test-run.pl
Please report any problems at http://mariadb.org/jira
The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/
参数解析
[root@test /]# mysql_install_db --help
...
--force Causes mysql_install_db to run even if DNS does not work. In that case, grant table entries that normally use hostnames will use IP addresses.
...
- 当无法使用DNS解析时,使用--force参数来强制使用ip进行初始化