Installation and compilation from source code 2/3

Compilation

Once the previous step is done, we can compile :

shell> make

The operation, which gives the reader the time to take a shower or a bath, or even go to the beach if the compilation takes place on a modest configuration, ends with the following four lines before returning the prompt :

Scanning dependencies of target my_safe_process
[100%] Building CXX object mysql-test/lib/My/SafeProcess/ CMakeFiles/my_safe_process.dir/safe_process.cc.o
Linking CXX executable my_safe_process
[100%] Built target my_safe_process

Installation completion

The installation of the application on the system ends with this next command :

shell> make install

By default, the installation takes place in the /usr/local/mysql/ folder. To change that, use the DESTDIR : make install DESTDIR= «/opt/ mysql» option.

The make install process ends with the following lines :

— Installing : /usr/local/mysql/mysql-test/lib/My/ SafeProcess/my_safe_process
— Up-to-date : /usr/local/mysql/mysql-test/lib/My/ SafeProcess/my_safe_process
— Installing : /usr/local/mysql/mysql-test/lib/My/ SafeProcess/Base.pm
— Installing : /usr/local/mysql/support-files/my-default. cnf
— Installing : /usr/local/mysql/support-files/mysqld_ multi.server
— Installing : /usr/local/mysql/support-files/mysql-logrotate
— Installing : /usr/local/mysql/support-files/magic
— Installing : /usr/local/mysql/share/aclocal/mysql.m4
— Installing : /usr/local/mysql/support-files/mysql.server

Then, we have to position ourselves in the installation folder :

shell> cd /usr/local/mysql

Affect it to the mysql user and to the eponymous group :

shell> chown -R mysql :mysql /usr/local/mysql

Finally it is necessary to use the following command to create the data folder in /var/lib/mysql :

shell> bin/mysqld –initialize –user=mysql –datadir=/ var/lib/mysql

Before MySQL 5.7.6, the data folder creation is done with mysql_install_db. For more information, refer to the paragraph dedicated to this utility in chapter 2

The root user password is generated automaticaly during the creation of the data folder. The password provision procedure differs depending on the method used (see previous remark). Remember to write it down and to change it at first connexion.

The log file /var/log/mysql/error.log has to end by this type of message :

A temporary password is generated for root@localhost : llE!jwAD>9/c

If it is not the case, search for the error message and delete the /var/lib/mysql folder this way

shell> rm -R /var/lib/mysql

Then, rely on the error cases below before repeating the operation.

-The following error can occur :
[ERROR] Can’t find error-message file ‘/usr/share/mysql/ errmsg.sys’. Check error-message file location and ‘lcmessages-dir’ configuration directive.
In that case, it is necessary to modify the lc-messages-dir directive inside the /etc/mysql/my.cnf configuration file :

lc-messages-dir = /usr/local/mysql/share

The datadir creation by mysqld --initialize generates a log in case of error. The following error can be found inside /var/log/mysql/error.log :

[ERROR] unknown variable ‘key_buffer=16M’

If necessary, correct the key_buffer=16M directive in the my.cnf file to :

#key_buffer=16M
key_buffer_size=16M

In the same file : /var/log/mysql/error.log, the following error can also be found :
[ERROR] unknown variable ‘myisam-recover=BACKUP’
In that case we have to comment the corresponding line in the my.cnf file, and to correct it as follow :

#myisam-recover = BACKUP
myisam_recover_options=BACKUP

It is necessary to set these two points before creating the datadir, else, the operation will be aborted

-The following warning can also come out :

[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use –explicit_defaults_for_timestamp server option (see documentation for more details).

The trick consists in adding the following line in the [mysqld] clause of my.cnf :

explicit_defaults_for_timestamp = 1

This topic is already covered in chapter 2 and in the mysql_install_db related paragraph.

If in the my.cnf file, the log folder is set in /var/log/mysql, remember to create the folder and to allow access to the mysql user :

shell> mkdir /var/log/mysql
shell> chown -R mysql :mysql /var/log/mysql