A week's summary of the wrong way to install mysql-5.7.13 from source code. full of tears

MySQL has been installed with cmake since 5.5.

5.7.5 Starting the installation environment requires the support of the boost library

Download the installation package:

https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.13.tar.gz

https://jaist.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz

tar decompresses the installation package.

Required compilation environment: make gcc gcc-c++ ncurses-devel openssl openssl-devel bison*

ps: The compilation environment must be fully installed, the bloody lessons learned from being pitted for two weeks.

Before the official installation, be sure to check whether the rpm package of MySQL is installed. Uninstall if any. Some systems will come with mariadb and it is recommended to uninstall as well.

Compile:

cmake . -DCMAKE_PREFIX=/usr/local/mysql \

-DMYSQL_DATADIR=/data/mydata \

-DSYSCONFDIR=/etc \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_ARCHIVE_STORAGE_ENGINE=1 \

-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

-DWITH_READLINE=1 \

-DWITH_LIBWRAP=0 \

-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \

-DWITH_SSL=system \

-DWITH_ZLIB=system \

-DWITH_BOOST=/document/tar/boost_1_59_0 \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci

ps: I feel that there are many parameters and it is difficult to write in the command line. It can be written as a script. If there is a problem, paste the problem on Baidu to find it. Basically it's a compilation environment problem. What package is missing can be directly packed in any package.

As long as there is no problem with the above, you can follow the make ; make install routine. This step is relatively slow, depending on the performance of the machine.

The installation is complete.

create mysql user

useradd mysql

Change the owner and group of the MySQL installation directory to mysql.

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

Create the mysql-files directory under the mysql directory

mkdir mysql-files

ps: There is no such directory by default. See other people create I also created. I don't know what it is for.

Then the initialization directory

./bin/mysqld --initialize --user=mysql

When initialized for the first time, there will be a string of garbled things at the end. That is a temporary password. (However, it's useless. Because you may not be able to start it at all)

ps: Initialization can only be done once by default. If continue to initialize. The data directory in the configuration file my.cnf needs to be cleared. Similarly, if you want to change the data storage directory. Also reinitialize.

 

Configuration file parsing:

[mysqld]

datadir=/data/mydata #Data directory

socket=/var/lib/mysql/mysql.sock    

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

skip-grant-tables #This is not available by default, skip password login.

# 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/mysql/error.log #Error log file

pid-file=/var/run/mysql/mysql.pid #Process PID

 

#

# include all files from the config directory

#

!includedir /etc/my.cnf.d

 

start mysql

./support-files/mysql.server start

ps: If you can start it up, you can only say that you are unlucky

If it doesn't start, check my.cnf

if:

[mysqld_safe]

log-error=/var/log/mariadb/error.log        

pid-file=/var/run/mariadb/mariadb.pid         

Change mariadb to mysql. Check to see if there are these two paths, and if not, create these two directories. Only directories are created, no files are created.

Note that the genus group and genus are mainly mysql.

Then reboot.

If the temporary password is forgotten or the temporary password cannot be logged in. Change the password: ./bin/mysqladmin -u root password "root" #Pay attention to the path problem.

If you get an error when logging in or changing your password:

[root@localhost mysql]# ./bin/mysql -uroot -p

Enter password:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

ps: I have been entangled with this problem for a day. The solution is to use find to find the mysql.sock file in the root directory. Then make a soft link to the error path.

[root@localhost mysql]# find / -name mysql.sock

find: '/run/user/1001/gvfs': insufficient permissions

/var/lib/mysql/mysql.sock

[root@localhost mysql]# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

Make changes according to different paths found by individuals. For specific principles, please refer to the link below. Very detailed.

https://www.cnblogs.com/Lam7/p/6090975.html     ps: Thanks

Then restart the service. You can log in by skipping the password first.

Add to my.cnf configuration file: skip-grant-tables

To change your password after logging in:

update mysql.user set authentication_string=password("root") where user;

 

ps: The whole process has been looking for problems and information for a week. I hope this article can make you take less wrong paths.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325012718&siteId=291194637