Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed explanation of the installation process of mysql and mariadb

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Download mysql and mariadb to find your own version:

Https://dev.mysql.com/downloads/mysql/

Because it has been compiled with cmake since 5.5. if it is not in the system, install it with the next source code, how to test whether it is installed in the system, enter # cma on the command line and press Tab to see if there is cmake, then the system has been installed, and you don't have to install it. If you have nothing to say, go to the next one, download address: https://cmake.org/download/

You need to install boost before you can install cmake,boost download address: https://sourceforge.net/projects/boost/files/boost/1.62.0/boost_1_62_0.tar.gz/download

Boost installation process:

Tar xf boost_1_59_0.tar.gz

Cd boost_1_59_0

. / bootstrap.sh if prompted, install the dependent library yum install gcc if there is no "error: no command provided, default command 'glossary' not found

"if there's a problem,

When the error is found, first confirm whether the corresponding package is missing in the system:

Rpm-qa | grep "glossy +"

After confirming that the system is not installed, query the packages of the corresponding features that can be installed:

Yum whatprovides "* / Gmail +"

On the given package

Yum install gcc-c++-4.8.5-11.el7.x86_64

The installation environment that yum install ncurses-devel-y needs when installing mysql. Maybe your machine has something else not installed. Take a closer look, just install it directly with yum.

Then install boost

. / b2

End

Cmake installation process:

Tar xf cmake-3.8.0-rc3.tar.gz

Cd cmake-3.8.0-rc3

. / configure

Gmake & & gmake install

Decompress: tar xf tar xf mariadb-5.5.46.tar.gz

Cd tar xf mariadb-5.5.46

Cmake. -LH looks at the options that can be configured and generates a CMakeCache.txt file

Cmake. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql

-DMYSQL_DATADIR=/data

-DSYSCONFDIR=/etc

-DWITHOUT_TOKUDB=1

-DWITH_INNOBASE_STORAGE_ENGINE=1

-DWITH_ARCHIVE_STPRAGE_ENGINE=1

-DWITH_BLACKHOLE_STORAGE_ENGINE=1

-DWIYH_READLINE=1-DWIYH_SSL=system

-DVITH_ZLIB=system

-DWITH_LOBWRAP=0

-DMYSQL_UNIX_ADDR=/tmp/mysql.sock

-DDEFAULT_CHARSET=utf8

-DDEFAULT_COLLATION=utf8_general_ci

Explain here:-DCMAKE_INSTALL_PREFIX is the specified installation location, here is / usr/local/mysql,-DMYSQL_DATADIR is the specified MySQL data directory, here is / data, the installation directory and data directory can be customized,-DSYSCONFDIR is the directory where the specified configuration file is located, usually / etc, the specific configuration file is / etc/my.cnf,-DWITHOUT_TOKUDB=1 this parameter is generally set on Does not install the tokudb engine, tokudb is an open source storage engine in MySQL, which can manage a large amount of data and has some new features that Innodb does not have. The reason why it is not installed here is that the general computer does not have Percona Server by default, and loading tokudb also depends on jemalloc memory optimization, which is generally not used in development, so it is temporarily blocked. Otherwise, no dependency can be found in the system: an error such as CMake Error at storage/tokudb/PerconaFT/cmake_modules/TokuSetupCompiler.cmake:179 (message) will occur, and then the following parameters are optional, either with or without. It is recommended to set the final encoding, so the compilation instructions can also be simplified as follows:

Note: if there is an error in the execution, you can execute: rm-f CMakeCache.txt delete the compilation cache and let the instruction be executed again, otherwise every time the file is read, the correct modification of the command will also report an error

Cmake is fine, you can compile and install:

Make & & make install takes a long time. Wait patiently.

Then there is the preparation process:

First of all, let's create a mysql user and a mysql user group. Why create it? Because you need mysql users to start the service when you start the service, but other users can't. If you want to ask me why, I don't know. Please ask Michael Widenius.

# groupadd-r mysql

# useradd-r-g mysql mysql

To change your installation directory and data directory to belong to the main group

Chown-R mysql.mysql / usr/local/mysql

Chown-R mysql.mysql / data

If you don't change it, you won't be able to afford your service after that.

Next, put the configuration file and startup file in the / etc directory

# cp / usr/local/mysql/support-files/my-huge.cnf / etc/my.cnf

# cp / usr/local/mysql/support-files/mysql.server / etc/init.d/mysqld

Modify the configuration file to add my data directory

Vim / etc/my.cnf

[mysqld]

Datadir = / data

Add PATH environment variable

Vim / etc/profile.d/mysql.sh

Export PATH=$PATH:/usr/local/mysql/bin

The current shell takes effect under source / etc/profile.d/mysql.sh read

The next step is to initialize the database:

Initialize:

# / usr/local/mysql/mysqld-- initialize-- user=mysql-- mysql5.7 version initialization

# / usr/local/mysql/bin/mysql_install_db-- user=mysql-- versions 5.6 to 5.7

# / usr/local/mysql/scripts/mysql_install_db-- user=mysql-- datadir=/data-version 5.5

Finally, start the database:

Service mysqld start

Set up boot boot:

Chkconfig mysqld on

Then you can connect to the database:

Mysql

Mysql > SET PASSWORD FOR root@'localhost'=PASSWORD ('mysql'); change the password, different versions have different ways to change, you can check it on the Internet.

Finally, there are some small ways to solve the problem:

If you do not give data directory permissions, the following problems occur:

Location of chown-R mysql:mysql datadir

* * remember to turn off the previous startup item, otherwise it will take up the PID file and you will find that you cannot start the process.

And your server-id is not set up.

Killall mysqld

1 、 Starting MySQL.. ERROR! The server quit without updating PID file (/ var/mysql/data/localhost.localdomain.pid).

It's the same problem with files like sockets:

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

3. It may be the second time to install mysql on the machine, and there is residual data that affects the startup of the service.

Solution: go to mysql's data directory and delete it if there is a mysql-bin.index.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report