Small c learning Linux(27)--mysql service installation

mysql general binary format installation


mysql binary format compression package


1) decompression

tar -xf mysql-5.5.58-linux-glibc2.12-x86_64.tar.gz

copy the extracted installation package to the system installation location / usr / local / mysql-5.5.58-linux-glibc2.12-x86_

cp -r mysql-5.5.58-linux-glibc2.12-x86_64 /usr/local/mysql-5.5.58-linux-glibc2.12-x86_64

#Create links for easy access later
cd /usr/local
ln -sv mysql-5.5.58-linux-glibc2.12-x86_64 mysql
cd mysql

3) View installation steps


Put the database content in the logical volume. The underlying layer of the logical volume should be the hardware raid

4) Create a logical volume for storing database data Reference lvm logical volume management

#1. Create partition sda3
fdisk /dev/sda

#2. Create a physical volume
pvcreate /dev/sda3

#3. Create a logical volume group
vgcreate mydata /dev/sda3

#4. Create a logical volume
lvcreate -L 10G -n mysqldata mydata

#5. Format logical volume
mke2fs -t ext4 /dev/mydata/mysqldata

#6. Create mount directory
vim /data/mydata

#7. Auto mount after power on
vim /etc/fstab
#/dev/mydata/mysqldata /data ext4 default 0 0

#8. Re mount fstab
mount -a

5) If you do not create logical volume storage data, create database data storage location directly

mkdir /data/mydata

6) Creating mysql system groups and system users

#To run and initialize database data
groupadd -r mysql
useradd -r -g mysql -s /sbin/no/login mysql

7) Initialize database data

#1. Modify the primary group under the / usr/local/mysql path
chown -R mysql:mysql /usr/local/mysql

#2. Modify the main genus group under the / data/mydata path
chown -R mysql:mysql /data/mydata

#3. Specify database data storage path and mysql user
scripts/mysql_install_db --datadir=/data/mydata --user=mysql

#4. Modify the owner under the / usr/local/mysql path
chown -R root /usr/local/mysql

8) Configure mysql service

#1. Copy service script
cp support_files/mysql.server /etc/rc.d/init.d/mysqld

#2. Make the service effective
chkconfig --add mysqld

#3. View mysqld service
chkconfig --list mysqld

#4. Copy mysql configuration script
cp support_files/my-large.cnf /etc/my.cnf

#5. Edit mysql configuration script, add and modify
thread-concurrency=cpu Physical core*2
datadir=/data/mydata       #Database path

9) Configure mysql command environment variables

vim /etc/profile.d/
export PATH=/usr/local/mysql/bin:$PATH

10) Give developers some information

#1. Developers do secondary development based on mysql
ln -sv /usr/local/mysql/include/ /usr/include/mysql

#2. Update the system library
ldconfig -p | grep mysql Contrast ls /usr/local/mysql/lib
#Edit profile
vim /etc/
#Make it effective
ldconfig -v

#3. Add man to the server
vim /etc/man.config
MANPATH = /usr/local/mysql/man

Change Password

#1. Run mysql as root
mysql -uroot -p -hlocalhost

#2. Enter with a blank password and change the root password
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456')

Use database

#1. Enter mysql as root
mysql -uroot -p -hlocalhost

#2. View database
show databases;

#3. Use mysql database
use mysql;

#4. View the data table of mysql database
show tables;

#5. View the definition of user database table
desc user;

#6. Query mysql users
select User,Host,Password from user;

#7. Delete unsafe users
drop user 'root'@'::1'

Keywords: MySQL Database Linux vim

Added by szym9341 on Tue, 31 Mar 2020 13:31:27 +0300