Why mysqld_multi can't start mysql? - mysql

In my my.cnf, I write:
[mysqld_multi]
mysqld = /usr/local/Cellar/mysql/5.7.11/bin/mysqld_safe
mysqladmin = /usr/local/Cellar/mysql/5.7.11/bin/mysqladmin
user = root
password =
[mysqld1]
pid-file = /usr/local/etc/mysql/mysqld.pid
socket = /usr/local/etc/mysql/mysqld.sock
port = 3306
datadir = /usr/local/var/mysql
log-bin=mysql-bin
server-id=1
[mysqld2]
pid-file = /usr/local/etc/mysql/mysqld1.pid
socket = /usr/local/etc/mysql/mysqld1.sock
port = 3307
datadir = /usr/local/var/mysql1
server-id=2
language=/usr/local/Cellar/mysql/5.7.11/share/mysql/english
user=mysql
Then I execute mysqld_multi start 2, and I get the error info:
Installing new database in /usr/local/var/mysql1
2016-09-19 19:37:16 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2016-09-19 19:37:16 [ERROR] Can't locate the language directory.
FATAL ERROR: Tried to start mysqld under group [mysqld2],
but no data directory was found or could be created.
data directory used: /usr/local/var/mysql1
I can't start the mysql process, so what's the problem? It seems the directory /usr/local/var/mysql1 has some problems, but the directory exists, it's confused.

It seems like mysqld_multi wasn't fixed to use mysqld --initialize.
You will have to run mysqld --initialize along with all directory related options in my.cnf for that server.
(from comment)
You can also fix the mysqld_multi script following the instructions in Running two instances of mysql.

Related

Failed to find valid data directory. MySQL generic binary installion

Im going to install mysql to linux server. But I dont have root access to that server. So I created two folders called mysql and mysqldata. mysql folder holds binary files. mysqldata folder holds data and the logs.
my.cnf
[mysqld]
user = mysql
port = 3306
bind-address = localhost
basedir = /home/nwn/mysql/mysql-8.0
socket = /home/nwn/mysqldata/instA/socket/mysql.sock
datadir = /home/nwn/mysqldata/instA/data
tmpdir = /home/nwn/mysqldata/instA/tmp
secure_file_priv = /home/nwn/mysqldata/instA/mysql-files
max_connections = 150
# Logging
log-bin = /home/nwn/mysqldata/instA/logs/instA-binlog
log-error = /home/nwn/mysqldata/instA/logs/instA-errorlog.err
slow_query_log = 1
slow_query_log_file = /home/nwn/mysqldata/instA/logs/instA-slowquery.log
long_query_time = 0.5
# InnoDB
innodb_data_home_dir = /home/nwn/mysqldata/instA/innodb/data
innodb_data_file_path = ibdata1:50M;ibdata2:12M:autoextend:max:500M
innodb_log_group_home_dir = /home/nwn/mysqldata/instA/innodb/log
innodb_buffer_pool_size = 32M
# MyISAM
key_buffer_size = 16M
server_id = 1
I did all the other configurations.
when I run following command
mysql-8.0]$ bin/mysqld --defaults-file=~/mysqldata/instA/my.cnf --initialize-insercure
I have following logs in the error_log
cat ~/mysqldata/instA/logs/instA-errorlog.err
2018-10-09T10:39:51.127424Z 0 [Warning] [MY-010139] [Server] Changed limits: max_open_files: 1024 (requested 8160)
2018-10-09T10:39:51.127523Z 0 [Warning] [MY-010142] [Server] Changed limits: table_open_cache: 432 (requested 4000)
2018-10-09T10:39:51.383986Z 0 [Warning] [MY-010101] [Server] Insecure configuration for --secure-file-priv: Location is accessible to all OS users. Consider choosing a different directory.
2018-10-09T10:39:51.384043Z 0 [System] [MY-010116] [Server] /home/nwn/mysql/mysql-8.0/bin/mysqld (mysqld 8.0.12) starting as process 32654
2018-10-09T10:39:51.386625Z 0 [Warning] [MY-010122] [Server] One can only use the --user switch if running as root
2018-10-09T10:39:51.394675Z 1 [ERROR] [MY-011011] [Server] Failed to find valid data directory.
2018-10-09T10:39:51.394817Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2018-10-09T10:39:51.394831Z 0 [ERROR] [MY-010119] [Server] Aborting
2018-10-09T10:39:51.395363Z 0 [System] [MY-010910] [Server] /home/nwn/mysql/mysql-8.0/bin/mysqld: Shutdown complete (mysqld 8.0.12) MySQL Community Server - GPL.
Even though the post is very old, but posting my solution as it took me around 2 hours to figure it out and this can help someone save that time.
You can try doing :
shell> mysqld --initialize
This shall initialse the data directory in the path where you have installed MySql server. Generally placed at C:\Program Files\MySQL\MySQL Server 8.0.
Hope it helps someone.
Please follow these steps to reset your MySQL Password on Windows:
Stop MySQL Service # services.msc
Create file change_mysql_pwd.txt with following content (replase YourNewPassword with desired new password you want to have for root user:
ALTER USER 'root'#'localhost' IDENTIFIED BY 'YourNewPassword';
Save the file under C:\ change_mysql_pwd.txt
Run CMD.exe as Admin (Start->Cmd->Right Click->Run as Administrator)
Type in cmd: cd "C:\Program Files\MySQL\MySQL Server 8.0\bin"
Create “Data” Folder under "C:\Program Files\MySQL\MySQL Server 8.0\ (if already exists delete its contents!)
Type in cmd: mysqld --install
Type in cmd: mysqld --initialize
Type in cmd: mysqld --init-file=C:\\change_mysql_pwd.txt
Login with root user account and the password set above.
Delete C:\ change_mysql_pwd.txt file
Enjoy...
(context: new setup, mysql 8 on windows server 2016)
What really helped me to get rid of "Failed to find valid data directory" was:
mysqld --initialize --console
The --console part tells you straight away on the command line what is wrong and what to do. Because I had a clean install, i lacked the "data" directory. However if you have settings in your my.ini that are not supported in the newly installed version, a "data" directory will be generated nevertheless with the command listed above. If you have more then one faulty setting in my.ini, you'll need to delete the newly created "data" directory first.
CAUTION: check first if you have databases in the data directory, else you'll loose all your databases!! So only use this on fresh installs.
In steps:
run mysqld --initialize --console from a cmd as administrator
fix the my.ini faulty line, delete the data directory (ONLY IF YOU HAVE A NEW INSTALLATION: else you'll loose all your databases!)
rerun mysqld --initialize --console
repeat until all errors are fixed.
Now MySql should start.
As far as I understand from your console output you try to initialize the database while there exist files in your data directory. First you should remove all files (please be careful here, you may loss your data) in the data directory of your MySQL, and then you should run the command below
shell> mysqld --initialize --console
as stated by #Alex Karshin, #Lazycoder_0071 and #Freeze_H. MySQL should initialize the database seamlessly if there isn't another problem.
What Kevin Kopf and Lazycoder_007 indicate in https://stackoverflow.com/a/62003723/7733418 worked for me fine, along with
deleting the files within the "data" folder before initialization (thanks to P D)
running mysqld --initialize in cmd as administrator

Running two instances of mysql

I'm trying to run two instances of MySQL on the same machine and setup my.cnf file as the following:
[mysqld1]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3307
datadir = /var/lib/mysql
[mysqld2]
user = mysql
pid-file = /var/run/mysqld/mysqld2.pid
socket = /var/run/mysqld/mysqld2.sock
port = 3308
datadir = /var/lib/mysql2
When I execute mysqld_multi start command, it arises the following error:
Installing new database in /var/lib/mysql2
2016-10-06 17:47:23 [WARNING] mysql_install_db is deprecated. Please
consider switching to mysqld --initialize 2016-10-06 17:47:23 [ERROR]
Can't locate the server executable (mysqld).
FATAL ERROR: Tried to start mysqld under group [mysqld2], but no data
directory was found or could be created. data directory used:
/var/lib/mysql2
How can I solve this?
Note: MySQL is running on Ubuntu 16.0.4 and MySQL 5.7
I know the one question.
2016-10-06 17:47:23 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize 2016-10-06 17:47:23 [ERROR] Can't locate the server executable (mysqld).
Please vim the line 343 to 344&345 in the file /use/bin/mysqld_multi
343 #$install_cmd="/usr/bin/mysql_install_db ";
344 $install_cmd="/usr/bin/mysqld ";
345 $install_cmd.="--initialize ";
346 $install_cmd.="--user=mysql ";
347 $install_cmd.="--datadir=$datadir";

Mysql: Can´t start Server debian wheezy

Everytime i try to start my mysql service i get the same error
Error message:
150130 15:56:31 [ERROR] Can't start server: Bind on TCP/IP port: Cannot assign requested address
150130 15:56:31 [ERROR] Do you already have another mysqld server running on port: 3305 ?
150130 15:56:31 [ERROR] Aborting
My Error log is empty
Conf file snippet:
[client]
port = 3305
socket = /var/run/mysqld/mysqld.sock
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3305
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
Sorry for my bad english
Complete Conf file
Looks like your port(3305) is occupied by another process.. you can :
1) switch to different port
2) kill/modify the process holding this port
(look it up using:
lsof -i :3305
)
in addition, this could be the cause of it (as one stated in this post) :
Change bind-address to 127.0.0.1 instead of localhost
Skipping network worked for me :
# echo "skip-networking" >> /etc/mysql/my.cnf
Then start mysql again.

OS X Mavericks: mysql socket defined in my.cnf, but not getting created

I'm trying to install mysql5 (the latest from Oracle, via .dmg) on OS X Mavericks. My /opt/local/my.cnf looks like this:
[client]
socket=/tmp/mysql.sock
[mysqld]
socket=/tmp/mysql.sock
[safe_mysqld]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
When I try to connect, I get the following:
$ mysql5 -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
And there is no /tmp/mysql.sock file created.
Here's my /tmp dir:
$ ls -l /tmp
lrwxr-xr-x# 1 root wheel 11 Oct 24 08:31 /tmp -> private/tmp
I've also tried forcing the socket from the command line:
$ time sudo mysqld_safe5 --socket=/tmp/mysql.sock
Password:
131221 07:26:02 mysqld_safe Logging to '/opt/local/var/db/mysql5/Macintosh.local.err'.
131221 07:26:02 mysqld_safe Starting mysqld daemon with databases from /opt/local/var/db/mysql5
131221 07:17:26 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
I know it's reading the conf file because if I remove it, I get a different socket location when I attempt to connect:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2)
But again, no luck. What do I need to do to get that socket created?
Change your /tmp folder to have permission for MySQL user. (chown mysql:mysql /tmp or chmod 777 /tmp would resolve your issue.)
Try using dtrace to see if mysqld is actually opening a socket, and if so, where. You'll also be able to tell what config files are being read by the server, although that doesn't seem to be the issue since passing --socket=... doesn't work.
I'm used to strace on Linux but recently started using dtrace at work. Here's a pretty simple example of how to trace open(2) calls, which you could modify to trace socket creation, or just all syscalls: https://github.com/tsibley/dtrace-scripts/blob/master/trace-open.d

my.cnf changing datadir, 2days and still no luck

Hi i have been trying this for hours upon hours, this forum is my last resort
sfter googling hundreds of pages.
PROBLEM:
Sorry for the length but i am supplying in detail of what i have tried
I have set up mysql and its working fine, i now need to change the data-storage to point at my External HD.
With mac osx there is no default my.cnf so i copied
my-huge.cnf from /usr/local/mysql-5.1.53-osx10.6-x86/support-files, now if it makes any odds i also have a 'mysql' folder in local also.
when i place and rename my-huge.cnf into /etc
i renamed it to my.cnf like instructed,
it works as normal if i dont add a datadir field which looks like this
datadir= /Volumes/Elements/database,
i have also copied my old data to my new location using
sudo cp -R -p /var/lib/mysql /Volumes/Elements/database
Everything workds fine unless i add the field datadir = /Volumes/Elements/database
to the my.cnf file, if i do i get the error
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
my.cnf file looks like the following
Macintosh-100:support-files seanf$ cd /etc
Macintosh-100:etc seanf$ sudo nano my.cnf
Password:
Macintosh-100:etc seanf$ nano my.cnf
Macintosh-100:etc seanf$ my.cnf > /Desktop/blah.txt
-bash: /Desktop/blah.txt: No such file or directory
Macintosh-100:etc seanf$ my.cnf < /Desktop/blah.txt
-bash: /Desktop/blah.txt: No such file or directory
Macintosh-100:etc seanf$ nano my.cnf
GNU nano 2.0.6 File: my.cnf
# Example MySQL config file for very large systems.
#
# This is for a large system with memory of 1G-2G where the system runs mainly
# MySQL.
#
# You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is /usr/local/mysql/data) or
# ~/.my.cnf to set user-specific options.
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.
# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]l
datadir = /Volumes/Elements/database
port = 3306
socket = /tmp/mysql.sock
skip-locking
key_buffer_size = 384M
etc....
I hope someone can shed light on this, i have an assignment due and have spent 2 days trying to get this working on my external
Also even when mysql is working and i type mysqld i get errors if this is an issue?
Macintosh-100:lib s$ mysqld
101201 13:31:13 [Warning] '--skip-locking' is deprecated and will be removed in a future >release. Please use '--skip-external-locking' instead.
101201 13:31:13 [Warning] Can't create test file /usr/local/mysql-5.1.53-osx10.6-x86/data>/Macintosh-100.lower-test
101201 13:31:13 [Warning] Can't create test file /usr/local/mysql-5.1.53-osx10.6-x86/data>/Macintosh-100.lower-test
mysqld: Can't change dir to '/usr/local/mysql-5.1.53-osx10.6-x86/data/' (Errcode: 13)
101201 13:31:13 [ERROR] Aborting
101201 13:31:13 [Note] mysqld: Shutdown complete
Macintosh-100:lib s$
Thanks for your time i hope an expert can answer this
Though I haven't played with datadir property but I've changed data storage location to the external HD by mounting default location to it as follows:
Backup your current data directory
Delete everything from your data directory
Mount it to your external HD (mount /var/lib/mysql/data /dev/XXX)
I've done it at Ubuntu Server. When changing InnoDB specific directories I've noticed that one have to be careful with rights (apparmord in case of ubuntu). When mysql cannot perform some filesystem operation I find its error messages very misleading. Sometimes it is really helpful to study it's error.log (/var/log/mysql/error.log in my case).
Hope this helps you to resolve your issue ASAP.
Use:
rsync -Pa /var/lib/mysql /Volumes/Elements/database
instead of:
cp -R -p /var/lib/mysql /Volumes/Elements/database
"rsync -a" can keep some permissions important for mysql.