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

Centos7.2 compilation and installation of mysql5.5.32

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Red Hat 7 and above the default database is no longer mysql, rpm and yum are installed in mariadb, but it is not impossible to install mysql, you can use compiler installation to install mysql.

Experimental environment: centos7.2

Lab objective: install and configure mysql5.5.32

New partition

First, create a new partition, quota, through fdisk to store mysql data:

Refresh hard disk information:

# partprobe devices

Format the new partition:

# mkfs.xfs / dev/vdb3

Create a mysql data mount point in the root directory (depending on the actual situation)

# mkdir / data

Edit / etc/fstab, add a new line to set the boot auto hang (parameters are based on the actual situation):

/ dev/vdb3 / data xfs defaults 0 0

Execute mount-av to mount automatically according to the fstab document:

# mount-av

Install mysql

Delete the mysql user before you start the installation, otherwise the compilation will not be successful. Pay attention to emptying all using-r.

# userdel-r mysql# grep mysql / etc/passwd

Create a mysql user and set it to 8001

# useradd-u 8001-s / sbin/nologin mysql

Install dependencies and necessary tools:

Yum-y install ncurses-develyum-y install cmakeyum-y install gcc-c++ start

Extract the mysql:

# tar xvf mysql-5.5.32.tar.gz

Start the compilation using cmake:

# cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_UNIX_ADDR=/tmp/mysql.sock-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci-DWITH_EXTRA_CHARSETS=all-DWITH_MYISAM_STORAGE_ENGINE=1-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_MEMORY_STORAGE_ENGINE=1-DWITH_READLINE=1-DENABLED_LOCAL_INFILE=1-DMYSQL_DATADIR=/data-DMYSQL_USER=mysql

Check the compilation status, and the output of 0 means it is successful:

# echo $?

Perform the installation:

# make & & make install

Authorize mysql users to mysql installation directory and data storage directory

Chown-R mysql:mysql / usr/local/mysql/chown-R mysql:mysql / datachmod 1777 / tmp

Looking at the my.cnf file under / etc, you can find that the file is not configured. Overwrite the configuration file in the system directory with the configuration file in the newly compiled folder.

Create a configuration:

# cp support-files/my-large.cnf / etc/my.cnf

Set the environment variable:

# echo 'export PATH=/usr/local/mysql/bin:$PATH' > > / etc/profile# source / etc/profile

Set the service script and set the boot to start automatically:

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

Add execution permissions to the script:

# chmod + x / etc/init.d/mysqld

The service script modifies 2 parameters (MySQL installation directory, data storage directory # vim / etc/init.d/mysqld):

Basedir=/usr/local/mysqldatadir=/data

Initialize the database:

Give the file execution permissions:

# chmod + x scripts/mysql_install_db

Initialize the database and see that 2 ok representatives executed successfully:

# / usr/local/mysql/scripts/mysql_install_db-defaults-file=/etc/my.cnf-basedir=/usr/local/mysql-datadir=/data-user=mysql

Initialize the security configuration:

Start the mysql service:

# service mysqld start

Direct execution:

# mysql_secure_installation

Enter:

Y: set password

Login mysql test: # mysql-u root-p

Add a global command:

# ln-s / usr/local/mysql/bin/mysql / bin/

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