Can't determine basedir from my_print_defaults mysqld

My environment is: centos7 + mysql5.7.26, today the following error when viewing the slow query log with mysqldumpslow command

[root@localhost ~]# mysqldumpslow -t 1
Can't determine basedir from 'my_print_defaults mysqld' output: --server-id=1
--port=3306
--character_set_server=utf8
--collation-server=utf8_general_ci
--lower_case_table_names=1
...省略

Translated means: unable to determine basedir (mysql installation directory) from 'my_print_defaults mysqld' output, the reason is because there is no set basedir parameter when you install mysql, mysql is the installation path of.

From the Internet to find some way needs to execute mysql_install_db command

mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data &

There needs to modify environment variables, and so on.

Because I now run mysql rpm package is installed, the installation directory during installation is automatically assigned the database directory, bin directory are all scattered, not concentrated, the above solutions are not appropriate, refer to the last moment solution of this article, MySQL slow queries Error: basedir from the Determine of Can not 'my_pri , in the previous command with the slow query log file name, this problem is solved.

[root@localhost ~]# mysqldumpslow -t 5 /var/lib/mysql/localhost-slow.log
Reading mysql slow query log from /var/lib/mysql/localhost-slow.log
Count: 2  Time=0.08s (0s)  Lock=0.00s (0s)  Rows=14.0 (28), root[root]@localhost
  show databases
Count: 8  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), root[root]@localhost
Count: 2  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=1.0 (2), root[root]@localhost
  show variables like 'S'

Analyze the reasons for this problem arising, if mysqldumpslow last command without the slow query log file address, reads mysql slow query log file address from the default configuration, the first step in determining the slow query log address is definitely determined mysql software installation path, because I was not configured at installation, so the above problem arises.

Guess you like

Origin www.cnblogs.com/goujian/p/11809318.html