我想在Ubuntu 14.04 x64下运行MySQL 5.7.13的多个实例,但是当我在my.cnf中创建一个名为[mysqld1]的新组并运行以下命令但不幸的是我收到此错误消息:
mbnoimivm@ubuntu:~$ sudo mysql_install_db --user=mysql --datadir=/var/lib/mysql1
[sudo] password for mbnoimivm:
2016-07-29 21:12:27 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2016-07-29 21:12:27 [ERROR] Can't locate the server executable (mysqld).
mbnoimivm@ubuntu:~$ sudo service mysql status
* MySQL Community Server 5.7.13 is running
mbnoimivm@ubuntu:~$
如何解决此问题?
配置文件
--- my.cnf ---
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
default-character-set = utf8
[mysqld_safe]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
explicit_defaults_for_timestamp
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
key_buffer_size = 384M
max_allowed_packet = 128M
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 256M
thread_cache_size = 8
query_cache_size = 256M
log-error = /var/log/mysql/error.log
symbolic-links=0
big-tables
default-storage-engine = MyISAM
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
slow-query-log = 1
slow-query-log-file = /var/log/mysql/slow.log
general-log = 1
general-log-file = /var/log/mysql/general.log
[mysqld1]
pid-file = /var/run/mysqld/mysqld1.pid
socket = /var/run/mysqld/mysqld1.sock
port = 3307
user = mysql
basedir = /usr
datadir = /var/lib/mysql1
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
default-character-set = utf8
no-auto-rehash
[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
!includedir /etc/mysql/conf.d/
答案 0 :(得分:0)
安装MySQL服务器大致涉及三个步骤:1)打开软件包装; 2)创建默认数据库; 3)创建默认用户/密码(并将其存储在数据库中)。
如果您不小心丢失了数据库文件(通常位于/ var / lib / mysql中),那么您可以重新启动而无需完全重新安装服务器软件包。这是通过命令mysqld --initialize完成的。如果在数据库已经存在的情况下运行此命令,它将报告错误("文件存在")并且它不会尝试覆盖数据库。但是,如果您不确定安装过程是否已正确完成,则可以删除目录/ var / lib / mysql并重新初始化数据库。
--initialize标志将导致MySQL生成root用户和随机密码,然后将其写入日志文件。有关更多信息,请参阅man mysqld。
答案 1 :(得分:0)
我遇到了同样的问题。我在 Ubuntu 18.0.4 中使用 apt-get install mysql-server-5.7
命令安装,浪费了 6 个多小时进行故障排除。我无法使用 mysqld --initialize
命令初始化实例 datadir,并出现“无法创建目录”或“权限被拒绝”错误,直到我下载了 新的 MySQL 包。
我选择通用的 Linux 版本 5.7.32,你可以direct download by click the link.