In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how MySQL is installed, the content of the article is carefully selected and edited by the author, with a certain pertinence, for everyone's reference significance is still relatively great, the following with the author to understand how MySQL is installed.
1. Compile and install mariadb with source code:
1. Toolkit installation (mariadb installation environment)
Yum install bison bison-devel zlib-devel libcurl-devel libarchive-devel boost-devel gcc gcc-c++ cmake ncurses-devel gnutls-devel libxml2-devel openssl-devel libevent-devel libaio-devel
2. Prepare the user and data directory
Mkdir / datauseradd-r-s / sbin/nologin-d / data/mysqldb-m mysqltar-xvf mariadb-10.2.15.tar.gz
3. Cmake compilation and installation:
One of the important features of cmake is its compilation function independent of the source code (out-of-source), that is, the compilation work can be done in the
In another specified directory rather than in the source directory, which ensures that the source directory will not be affected by any compilation
So many different compilations can be done on the same source tree, such as for different platforms
Go to the folder of the extracted source package: cd mariadb-10.2.15/
Copy the following code and execute:
Cmake\
-DCMAKE_INSTALL_PREFIX=/app/mysql\
-DMYSQL_DATADIR=/data/mysqldb\
-DMYSQL_UNIX_ADDR=/app/mysql/data/mysql.sock\
-DENABLED_LOCAL_INFILE=1\
-DWITH_INNOBASE_STORAGE_ENGINE=1\
-DWITH_ARCHIVE_STORAGE_ENGINE=1\
-DWITH_BLACKHOLE_STORAGE_ENGINE=1\
-DWITH_FEDERATED_STORAGE_ENGINE=1\
-DWITH_EXAMPLE_STORAGE_ENGINE=1\
-DWITH_PARTITION_STORAGE_ENGINE=1\
-DWITH_MYISAM_STORAGE_ENGINE=1\
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1\
-DMYSQL_TCP_PORT=3306\
-DEXTRA_CHARSETS=all\
-DDEFAULT_CHARSET=utf8\
-DDEFAULT_COLLATION=utf8_general_ci\
-DMYSQL_USER=mysql\
-DWITH_DEBUG=0
Compilation parameter description
Cmake\
-DCMAKE_INSTALL_PREFIX=/app/mysql\ # root directory of the installation
-DMYSQL_DATADIR=/data/mysqldb\ # data storage directory
-DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock\ # UNIX socket file
-DENABLED_LOCAL_INFILE=1\ # enable loading of local data
-DWITH_INNOBASE_STORAGE_ENGINE=1\ # supports InnoDB engine
-DWITH_ARCHIVE_STORAGE_ENGINE=1\ # supports ARCHIVE engine
-DWITH_BLACKHOLE_STORAGE_ENGINE=1\ # supports BLACKHOLE engine
-DWITH_FEDERATED_STORAGE_ENGINE=1\ # supports FEDERATED engine
-DWITH_EXAMPLE_STORAGE_ENGINE=1\ # supports EXAMPLE engine
-DWITH_PARTITION_STORAGE_ENGINE=1\ # supports PARTITION engine
-DWITH_MYISAM_STORAGE_ENGINE=1\ # supports MYISAM engine
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1\ # supports PERFSCHEMA engine
-DMYSQL_TCP_PORT=3306\ # default port open to the public
-DEXTRA_CHARSETS=all\ # supports all extended character support
-DDEFAULT_CHARSET=utf8\ # default character set is utf8 latin
-DDEFAULT_COLLATION=utf8_general_ci\ # default character proofreading utf8
-DMYSQL_USER=mysql\ # specify the mysql startup user
-DWITH_DEBUG=0 # debug mode
After execution, start the compilation and installation, and execute the following command:
Make & & make install (number of cpu cores can be specified-j [number])
Tip: if there is an error, execute rm-f CMakeCache.txt
4. Prepare environment variables
Echo 'PATH=/data/mysql/bin:$PATH' > / etc/profile.d/mysql.sh
Re-execute the initialization file you just modified to take effect immediately:
. / etc/profile.d/mysql.sh (or source)
5. Generate database files
Cd / app/mysql/scripts/mysql_install_db-datadir=/data/mysqldb/-user=mysql
6. Prepare the configuration file
Cp / data/mysql/support-files/my-huge.cnf / etc/my.cnf
7. Prepare the startup script
Cp / app/mysql/support-files/mysql.server / etc/init.d/mysqld
8. Start the service
Chkconfig-- add mysqld; service mysqld start
General binary format installation
Note: this method of installation we use LVM logical volumes to install
1. The storage space and logical volume of the database
Fdisk / dev/sdapartprobe pvcreate / dev/sda6vgcreate vg0/ dev/sda6lvcreate-n mysql-l + 100%FREE vg0mkfs.xfs / dev/vg0/mysql
Mount the logical volume created above, and set the boot to mount automatically.
Mkdir / datamount / dev/vg0/mysql / datavim / etc/fstab
2 create a mysql system user
Useradd-r-s / sbin/nologin-d / data/mysql-m mysql
3 the corresponding path for storing binary programs
Tar xvf mariadb-10.2.16-linux-x86_64.tar.gz-C / usr/local/cd / usr/local/
Create a soft connection mysql under the current directory
Ln-s mariadb-10.2.16-linux-x86_64/ mysql
Change the group to mysql
Chown-R root.mysql / usr/local/mysql/
4 PATH variable
Vim / etc/profile.d/mysql.shPATH=/usr/local/mysql/bin:$PATH. / etc/profile.d/mysql.sh
5 create database-related data files (initialize database)
Cd / usr/local/mysql/scripts/mysql_install_db-datadir=/data/mysql-user=mysql
6 prepare Mysql configuration file
Cp / usr/local/mysql/support-files/my-huge.cnf / etc/my.cnfvim / etc/my.cnfdatadir=/data/mysql
7 prepare to start the script
Chkconfig-listcp / usr/local/mysql/support-files/mysql.server / etc/init.d/mysqldchkconfig-add mysqldchkconfig-listservice mysqld start
8 start the script for security reinforcement
Mysql_secure_installation
Mariadb has been installed at this point.
3. MySQL multi-instance installation (yum)
1. Create mysql-related directories
Mkdir / mysqldb/ {3306, 3307, 3308} / {etc,bin,data,pid,socket,log}-pv
2. Yum install MariaDB-server
Yum install mariadb-server
3. Change the permissions to which the directory belongs
Chown-R mysql.mysql / mysqldb/
4. Generate database files
Mysql_install_db-datadir=/mysqldb/3306/data-user=mysqlmysql_install_db-datadir=/mysqldb/3307/data-user=mysqlmysql_install_db-datadir=/mysqldb/3308/data-user=mysql
5. Prepare the configuration file
Cp / etc/my.cnf / mysqldb/3306/etc/vim / mysqldb/3306/etc/my.cnf [mysqld] port=3306datadir= / mysqldb/3306/datasocket=/mysqldb/3306/socket/ mysql.sock [mysqld _ safe] log-error=/mysqldb/3306/log/mariadb.logpid-file=/mysqldb/3306/pid/mariadb.pidcp / mysqldb/3306/etc/my.cnf / mysqldb/3307/etc/cp / mysqldb/3306/etc/my.cnf / mysqldb/3308/etc/sed-I / 3306 / G'/ mysqldb/3307/etc/my.cnfsed-I's mysqldb/3308/etc/my.cnf 3306 / mysqldb/3308/etc/my.cnf
6. Generate startup script
Cp mysqld / mysqldb/3306/bin/vim / mysqldb/3306/bin/mysqld chmod + x / mysqldb/3306/bin/mysqld Note: the mysqld script is written in advance. Here is a link for download.
Https://pan.baidu.com/s/1AI_VZf7vvopfJzvZMpAI2A
7. Start and shut down the service
/ mysqldb/3306/bin/mysqld start/mysqldb/3306/bin/mysqld stop/mysqldb/3306/bin/mysqld restart Note: 3306, 3307, 3308 start the service the same
8. Specify the socket file to start mysql services on different listening ports
Mysql-S / mysqldb/3306/socket/mysql.sock mysql-S / mysqldb/3307/socket/mysql.sock mysql-S / mysqldb/3308/socket/mysql.sock
9. Modify the root password
Mysqladmin-S / mysqldb/3306/socket/mysql.sock password 'centos' Note: because the password (centos) is added in the execution script, if you do not modify the root password, you will get an error of 3307 and 3308 when starting stop.
After reading the above about how MySQL is installed, many readers must have some understanding. If you need more industry knowledge and information, you can continue to follow our industry information column.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.