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

How to use binary compilation to install MySql under Linux

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly describes how to use binary compilation to install MySql under Linux, the article is very detailed, has a certain reference value, interested friends must read it!

//at that time, i installed this and also tossed it around for an afternoon, so i wrote a note to record it;

//If there is a problem, we can discuss it together ( qq: 2970911340, email +@qq.com). This is also my first blog practice.

1. cmake tools

# yum install -y cmake

2. Creating MySQL Users

#useradd -s /sbin/nologin mysql //Set as non-logged in user (safe)

3. Create a data directory, which is used for databases, tables, logs, etc. generated during database initialization. Do not store things directly under this directory.

# mkdir -p /mysql/data //directory name is arbitrary (corresponding to later settings), but the remaining space in the partition where the directory is located cannot be less than 1g (not very clear)# chown mysql.mysql /mysql/ -R //Set the primary group of the directory to mysql

4. Install development packages required for compilation, etc.

# yum install ncurses-devel openssl-devel gcc* -y

5. Extract mysql binary package and compile

# cd /packet //cd to the directory where the package is stored # tar xvf mysql-5.6.22.tar.gz# cd mysql-5.6.22//directly start compiling, note: be sure to enter the decompressed mysql package in the edit and then cmake a lot of parameters there are some can be omitted #cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mysql/data -DDEFAULT_CHARSET=utf8 -DEXTRA_CHARSETS=all -DDEFAULT_COLLATION=utf8_general_ci -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_SSL=bundled/ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql //specify installation directory//-DMYSQL_DATADIR=/mysql/data //specify data directory, The one created above//others are slightly...

6. Error resolution (generally speaking, according to the above, there is no error)

# rm -rf CMakeCache. txt//When compiling errors, be sure to delete CMakeCache.txt and recompile it. When compiling this file, it will automatically generate some information like "bookkeeping book" when compiling.// The error book is temporarily put aside and updated later...

7. installation

# make -j 4 // -j 4 uses 4 cores to compile, because compilation takes a long time, so give it a few u# make install

8. initialization

# yum install -y perl-Data-Dumper //You will be prompted to install this # /usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/mysql/data/ -basedir=/usr/local/mysql//After initialization, you can see the generated basic library and logs in/mysql/data////client21.err The requested URL/data/client21.err was not found on this server.

9. Start configuration. Start.

# cp /usr/local/mysql/test/include/default_my.cnf /etc/my. cnf //This file is the configuration file of mysql service # cat > /etc/my.cnf //Delete the contents inside otherwise there will be problems later, you can also add some options to # /usr/local/mysql/bin/mysqld_safe --user=mysql & /Put it in the background to start, without adding '&' the current terminal will be abolished, you can try

//Of course, there may be some headaches in the middle, and there will be time to follow the new...

eg: Check the train of thought to see the prompt information, the address of the error log, where to start

1. selinux is closed//setenforce 0 temporarily closed

2. Is initialization normal?

3. CP/etc/my.cf configuration file datadir is correct

10. Define commands as system commands (you can skip this step)

# vim /etc/profile.d/mysql.sh export PATH=/usr/local/mysql/bin:$PATH //just add this line # source /etc/profile.d/mysql.sh

11. Set up boot up

# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld# chkconfig --add mysqld //Add mysqld to the boot managed by chkconfig # chkconfig --list| grep mysqld //Check if mysqld is powered on in each run level Start mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off

And after setting up, you can directly use systemctl restart| start mysqld control,( stop can not be used, temporarily do not know why you can use ' pkill mysqld ' instead)

12. Local test access, download mysql client on local machine (not service oh)

# yum install -y mysql //Mariadb client installed in this way, the experience will be a little better than my mysql. In fact, they are all the same # mysql. //Go directly in and test if there is any problem

//If you can read and write normally, there is no problem, very good !

The above is "Linux how to use binary compilation to install MySql" all the content of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!

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

Servers

Wechat

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

12
Report