[MDEV-7346] problems installing mariadb from source Created: 2014-12-18  Updated: 2014-12-21  Due: 2015-01-24  Resolved: 2014-12-20

Status: Closed
Project: MariaDB Server
Component/s: Compiling
Affects Version/s: 5.5.40
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: kylix Assignee: Unassigned
Resolution: Not a Bug Votes: 0
Labels: centos
Environment:

Windows 7, 64 bit
Using Virtualbox 4.3.12 and running CentOS 7



 Description   

I have been trying to install mariadb 5.4.20 since I can remember, it actually makes me feel if anyone has installed it yet on centos from build.

Anyway, I followed these steps,
https://gist.github.com/samayo/305ef8a08a4a4ec9f9c7
and here the error that keeps appearing.

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

I can't find mysql.sock file anywhere in my virtualbox.



 Comments   
Comment by Elena Stepanova [ 2014-12-19 ]

Hi,

What is MariaDB 5.4.20?

In the paste you apparently skipped some steps, but it's impossible to say how many and which, so proper diagnostics is impossible.

You don't create mysql user, but I don't see any mention of complaints about it missing. Do you already have it?
Right after make install you run mysql_install_db from the current datadir. There will be no mysql_install_db in the current datadir, so apparently something else happened between the two commands. What was it?
You don't install the service, but somehow it exists at the moment you run it.Where did you get it?

Which user are you running all the commands from, root?
Where do you see the message about the missing socket?
Is the mysqld process running?

Comment by kylix [ 2014-12-20 ]

Hi Elena.

First thank you very much for your response, this means so much to me. I have not been able to work on my project for 3 days, because it is very important that I get past this problem first.
Now, with my apologies for the lack of clarity in my question (I could not concentrate due to hours of exhaustion trying find a solution for the problem ) here is a clarification.

As I said, I have HP, Windows 7 64bit system. I have installed a VirtualBox 4.3.12 and I am using the CentOS 7 distro of Linux.

My aim is simple, to build/compile mariadb (I believe the latest stable version is 5.4.20 as seen in this link https://downloads.mariadb.org/mariadb/5.5.40/ ) from source code.

I know there are easier (rpm) ways to get latest version of mariadb on CentOs but I prefer to build it from source as seen in this example http://www.yongbok.net/blog/how-to-install-mariadb-source-on-linux/

I followed the tutorial on the site link above, It didn't work for me, but also since I had cmake version 2.8.11 I didn't manually download it, as mentioned there. So, here is line by line code I run until I get the problem again.
I just did this 30 minutes ago, after formatting and using a fresh CentOs 7 install.

mariadb build steps

// Update CentOs to use latest and stable tools
$ yum -y update
 
// Install the tools that are required to run build / run MariaDB
$ yum -y install cmake glibc.i686 ncurses-devel
 
// Get a copy of the current mariadb source code
$ wget https://downloads.mariadb.org/f/mariadb-5.5.40/source/mariadb-5.5.40.tar.gz
$ tar xzvf mariadb-5.5.40.tar.gz
$ cd mariadb-5.5.40
$ mkdir build 
$ cd build
 
// configure the install with the below settings. 
 cmake ..  -DWITH_READLINE=1  -DWITH_SSL=bundled  -DWITH_ZLIB=system  -DDEFAULT_CHARSET=utf8  -DDEFAULT_COLLATION=utf8_general_ci  -DENABLED_LOCAL_INFILE=1  -DWITH_EXTRA_CHARSETS=all  -DWITH_ARIA_STORAGE_ENGINE=1  -DWITH_XTRADB_STORAGE_ENGINE=1  -DWITH_ARCHIVE_STORAGE_ENGINE=1  -DWITH_INNOBASE_STORAGE_ENGINE=1  -DWITH_PARTITION_STORAGE_ENGINE=1  -DWITH_BLACKHOLE_STORAGE_ENGINE=1  -DWITH_FEDERATEDX_STORAGE_ENGINE=1  -DWITH_PERFSCHEMA_STORAGE_ENGINE=1  -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb  -DMYSQL_DATADIR=/usr/local/mariadb/data
 
// make and make install
$ make 

I will just show you that what I saved after this.

Now, here is the next step I took.

mariadb build steps

$ make install
$ groupadd -g 27 -o -r mysql
$ useradd -M -g mysql -o -r -d /usr/local/mariadb/data -s /bin/false -c “MariaDB” -u 27 mysql
$ mkdir -p /usr/local/mariadb/InnoDB/{redoLogs,undoLogs,ib_data}
$ chgrp -R mysql /usr/local/mariadb
$ chown -R mysql /usr/local/mariadb/data
$ mkdir /usr/local/mariadb/logs /usr/local/mariadb/tmp
$ chown mysql:mysql /usr/local/mariadb/{tmp,logs}
$ cd /usr/local/mariadb/scripts

All the above went ok, but when I did

 ./mysql_install_db –basedir=/usr/local/mariadb –datadir=/usr/local/mariadb/data

I get this error.

mariadb error 1

FATAL ERROR: Could not find ./bin/my_print_defaults
 
If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.
 
If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.
 
The latest information about mysql_install_db is available at
https://mariadb.com/kb/en/installing-system-tables-mysql_install_db

I then tried this.

./mysql_install_db --basedir=/usr/local/mariadb/

and I got this.

mariadb build steps

[root@localhost scripts]# ./mysql_install_db --basedir=/usr/local/mariadb/
Installing MariaDB/MySQL system tables in '/var/lib/mysql' ...
OK
Filling help tables...
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/local/mariadb//bin/mysqladmin' -u root password 'new-password'
'/usr/local/mariadb//bin/mysqladmin' -u root -h localhost.localdomain password 'new-password'
 
Alternatively you can run:
'/usr/local/mariadb//bin/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/local/mariadb/' ; /usr/local/mariadb//bin/mysqld_safe --datadir='/var/lib/mysql'
 
You can test the MariaDB daemon with mysql-test-run.pl
cd '/usr/local/mariadb//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
Support MariaDB development by buying support/new features from
SkySQL Ab. You can contact us about this at sales@skysql.com.
Alternatively consider joining our community based development effort:
http://mariadb.com/kb/en/contributing-to-the-mariadb-project/
 
[root@localhost scripts]#
 

if I try

'/usr/local/mariadb//bin/mysqladmin' -u root password 'new-password'

I get this error.

mariadb build steps

[root@localhost scripts]# '/usr/local/mariadb//bin/mysqladmin' -u root password 'new-password'
/usr/local/mariadb//bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!

Here are some scripts I execute and results I got.

tmp dir

[root@localhost scripts]# ls -l /tmp/
total 28
-rw-r--r--. 1 root root     0 Dec 19 15:51 cc2tVH04.ltrans0.ltrans.gcno
-rw-r--r--. 1 root root     0 Dec 19 15:51 cc2tVH04.ltrans1.ltrans.gcno
-rw-r--r--. 1 root root     0 Dec 19 15:51 cc2tVH04.ltrans2.ltrans.gcno
-rwx------. 1 root root   663 Nov 19 15:19 ks-script-XnW0Nx
drwxr-xr-x. 3 root root    17 Dec 18 07:20 pear
-rw-------. 1 root root   199 Dec 17 20:28 tmpcuohS_
-rw-r--r--. 1 root root 20215 Nov 20 15:13 vboxguest-Module.symvers
-rw-------. 1 root root     0 Nov 19 14:53 yum.log
[root@localhost scripts]#
 

my.cnf

# vi /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
 
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
 
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

mysqld_safe

[root@localhost scripts]# ../bin/mysqld_safe
141219 16:52:23 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
touch: cannot touch ‘/var/log/mariadb/mariadb.log’: No such file or directory
chmod: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory
touch: cannot touch ‘/var/log/mariadb/mariadb.log’: No such file or directory
chown: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory
141219 16:52:23 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
../bin/mysqld_safe: line 138: /var/log/mariadb/mariadb.log: No such file or directory
../bin/mysqld_safe: line 182: /var/log/mariadb/mariadb.log: No such file or directory
touch: cannot touch ‘/var/log/mariadb/mariadb.log’: No such file or directory
chown: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory
chmod: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory
141219 16:52:23 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended
../bin/mysqld_safe: line 138: /var/log/mariadb/mariadb.log: No such file or directory
[root@localhost scripts]#

mysql_secure_install

[root@localhost scripts]# ../bin/mysql_secure_installation
../bin/mysql_secure_installation: line 379: find_mysql_client: command not found
 
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
 
In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
 
Enter current password for root (enter for none):
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Enter current password for root (enter for none):
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Enter current password for root (enter for none):

mysql status

[root@localhost scripts]# mysqladmin -u root -p status
-bash: mysqladmin: command not found
[root@localhost scripts]#

mysql status #2

[root@localhost scripts]# /etc/init.d/mysql status
-bash: /etc/init.d/mysql: No such file or directory
[root@localhost scripts]#

locate pid

[root@localhost scripts]# ps aux |grep mysqld
root      4021  0.0  0.1 112640   968 pts/1    S+   16:57   0:00 grep --color=auto mysqld
[root@localhost scripts]#

I have tried rebooting my virtualbox, network restart, chmo 777 my temp /tmp ... just above every solution I could find on the net
I hope I can get help in this site. and I also have root privileges

thanks so much and sorry for wasting your time.

Comment by Elena Stepanova [ 2014-12-20 ]

Hi,

Okay, I see there is a lot of mix up here.

You have made all preparations for the datadir in /usr/local/mariadb/data. It's okay. But this command was bad:

 ./mysql_install_db –basedir=/usr/local/mariadb –datadir=/usr/local/mariadb/data

Note that for both options you have single dashes instead of double hyphens! That's why it didn't work.

Then you replaced it with a properly formed command line

./mysql_install_db --basedir=/usr/local/mariadb/

But now you skipped the non-default datadir. The command worked not because you skipped the datadir, but because you now provided basedir in a proper way.
However, since you skipped the datadir, system tables were installed in /var/lib/mysql, just like the output says.

Then you run mysqladmin. Naturally it fails because you didn't start the server yet (mysql_install_db only starts the server temporarily, to create system tables, and then shuts it down). The error "Can't connect to local MySQL server through socket '/tmp/mysql.sock" is quite literal here – mysqladmin cannot connect to the server, because there is no server and hence no socket.

Then you run mysqld_safe (which is supposed to start the server), and get a bunch of "No such file or directory" errors – naturally, since you did not create /var/log/mariadb/ folder, but you attempt to write the log there (it's in your cnf file). Same goes for /var/run/mariadb where the pid file is supposed to be placed – you have it in my.cnf, but you never created it. So again, the server didn't start.

Then you attempt to run ./bin/mysql_secure_installation which of course can't work either, because the server is still not running.

Then you attempt to run mysqladmin without a proper path to the binary, and it tells you that the command was not found (naturally, it's not on the path, you installed it into a custom folder)

Then you attempt to run /etc/init.d/mysql, and it doesn't exist either, because you didn't create it.

And of course there is no process since your only attempt to run the server failed due to the non-existing folders.

What you need to do is to sort out your data/log folders. Now you have 3 variations:

/usr/local/mariadb/data is what you created;
/var/lib/mysql is where your system tables got installed;
/var/log/mariadb/ and /var/run/mariadb/ is where you attempt to write even though they don't exist.

Comment by kylix [ 2014-12-20 ]

Hello Elena.

Thank you for the help, I realize that I only use one hyphen in the example, but had actually tried it with 2 hyphens first. So, this morning I removed everything in started over again, following the example I gave youline by line upto the line that caused the error in which I replaced it to the below (with double hyphens)

./mysql_install_db --basedir=/usr/local/mariadb --datadir=/usr/local/mariadb/data

and this is the error I get.

So, I am assuming this must be a bug that needs to be fixed?

Comment by Elena Stepanova [ 2014-12-20 ]

It's always possible that there is a bug somewhere, but I already tried the whole chain of actions that you described previously and it worked all right (with the properly formed command line). Without more information, and taking into account the previous experience, my best guess is that there was some other mix up on the way this time.
If you want the diagnostics for your problem, you need to paste the whole unabridged set of steps that you performed, preferably the direct copy-paste from the console.

Alternatively, if it's a test machine, you can give me an access to it and I'll look at your current installation to see what the problem is. My public SSH key is here: https://launchpad.net/~elenst/+sshkeys

Comment by kylix [ 2014-12-20 ]

Ok, I just bought 8GB Ram 80GB SSD, CentOS 7.0 x64 from DigitalOcean for testing purpose, I added your ssh key, but if you want direct access here you go

ssh root@104.236.80.239

It is just for test and I will remove it later. I have no content.

I started with these commands,

$ yum -y update
$ yum -y install cmake glibc.i686 ncurses-devel gcc
$ cd /usr/local/src/
$ wget https://downloads.mariadb.org/f/mariadb-5.5.40/source/mariadb-5.5.40.tar.gz
$ tar xzvf mariadb-5.5.40.tar.gz
$ cd mariadb-5.5.40
$ mkdir build 
$ cd build
 
// this caused me error
 cmake ..  -DWITH_READLINE=1  -DWITH_SSL=bundled  -DWITH_ZLIB=system  -DDEFAULT_CHARSET=utf8  -DDEFAULT_COLLATION=utf8_general_ci  -DENABLED_LOCAL_INFILE=1  -DWITH_EXTRA_CHARSETS=all  -DWITH_ARIA_STORAGE_ENGINE=1  -DWITH_XTRADB_STORAGE_ENGINE=1  -DWITH_ARCHIVE_STORAGE_ENGINE=1  -DWITH_INNOBASE_STORAGE_ENGINE=1  -DWITH_PARTITION_STORAGE_ENGINE=1  -DWITH_BLACKHOLE_STORAGE_ENGINE=1  -DWITH_FEDERATEDX_STORAGE_ENGINE=1  -DWITH_PERFSCHEMA_STORAGE_ENGINE=1  -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb  -DMYSQL_DATADIR=/usr/local/mariadb/data

as soon as I tried to configure it with the last command in the above code, I got ...

-- The CXX compiler identification is unknown
CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
-- Configuring incomplete, errors occurred!

So, this means, I had even far less success with a vps that my virtualbox.

I would be grateful, if you could just test it and let me know what it worked for you.

Comment by Elena Stepanova [ 2014-12-20 ]

Well, this error is natural, you really don't appear to have an CXX compiler on the machine. Install it.

Please also note that currently your mariadb-5.5.40/CMakeLists.txt file is empty – I don't know how you achieved this, but make sure you've created a new source dir before you try again (after you've installed the compiler and whatever else is necessary to actually build the server).

Please comment when you reach the point of the original mysql_install_db problem.

Comment by Elena Stepanova [ 2014-12-20 ]

Here is what I have when I ssh to your machine, cd to the same dir and run the same command (but typed manually in the command line):

[root@kylix ~]# cd /usr/local/mariadb/scripts/
[root@kylix scripts]# ./mysql_install_db --basedir=/usr/local/mariadb --datadir=/usr/local/mariadb/data
Installing MariaDB/MySQL system tables in '/usr/local/mariadb/data' ...
OK
Filling help tables...
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/local/mariadb/bin/mysqladmin' -u root password 'new-password'
'/usr/local/mariadb/bin/mysqladmin' -u root -h kylix password 'new-password'
 
Alternatively you can run:
'/usr/local/mariadb/bin/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/local/mariadb' ; /usr/local/mariadb/bin/mysqld_safe --datadir='/usr/local/mariadb/data'
 
You can test the MariaDB daemon with mysql-test-run.pl
cd '/usr/local/mariadb/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
Support MariaDB development by buying support/new features from
SkySQL Ab. You can contact us about this at sales@skysql.com.
Alternatively consider joining our community based development effort:
http://mariadb.com/kb/en/contributing-to-the-mariadb-project/

The reason why you are getting the error is that you are still not using double-hyphens. Here is what I see in the history:

  154   cd /usr/local/mariadb/scripts
  155  ./mysql_install_db -–basedir=/usr/local/mariadb -–datadir=/usr/local/mariadb/data
  156  exit
  157  cd /usr/local/mariadb/scripts/
  158  ./mysql_install_db --basedir=/usr/local/mariadb --datadir=/usr/local/mariadb/data

154-156 are your commands. 157-158 are mine. Do you see the difference between 155 and 158?

Comment by kylix [ 2014-12-20 ]

its hard to make any sense out of this, but it worked!!!

I have dealt with mis-typed errors before, but this one takes the cookie.

anyway, thank you so much and sorry for killing your time with my retarded question. <3

Comment by Elena Stepanova [ 2014-12-20 ]

You are welcome.
Please change the password if you haven't done it yet. I made your comment with it private, but it went public initially, which is no good even for a test box.
And you can remove my ssh key now since the problem has been resolved.

Comment by kylix [ 2014-12-21 ]

No worries, But I destroyed to entire vps, that is my definition of security, if & when I share sensitive data

thanks again && cheers

Generated at Thu Feb 08 07:18:53 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.