6.2.3 Installing MySQL database

6.2.3 Installing MySQL database

1. Installation Overview

  • yum / rpm packages installed
  • Binary installation
  • Source Installation
  • Source software combined with yum / rpm installation
安装MySql注意事项
1   建议与Nginx安装在同一台机器上
2   重视操作过程的报错,有错误解决掉再继续,不能忽略编译中错误。

Installation procedure

1) Create a user account mysql combination

groupadd mysql
useradd -s /sbin/nologin -g mysql -M mysql
tail -1 /etc/passwd
id mysql

Establish fixed directory holding the installation software

mkdir -p /home/oldboy/tools
cd /home/oldboy/tools

2) obtain MySQL installation package
Download
https://cdn.mysql.com/archives/mysql-5.5/mysql-5.5.32-linux2.6-x86_64.tar.gz
downloadable version of mysql-5.5.32-linux2.6 -x86_64.tar.gz binary packages

QOfa1x.jpg

3) mounted binary MySQL

rz
 tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz
 mkdir -p /application/
 mv mysql-5.5.32-linux2.6-x86_64 /application/mysql-5.5.32
 ln -s /application//mysql-5.5.32/ /application/mysql
 ls -l /application/mysql

Tip: extracting binary packages as long as no need to perform cmake / configure, make, make install process and the like

4) the initialization MySQL configuration file my.cnf

cd /application/mysql
ls -l support-files/*.cnf
/bin/cp support-files//my-small.cnf /etc/my.cnf 
/bin/cp support-files/my-small.cnf /etc/my.cnf 

5) MySQL database initialization file

 mkdir -p /application/mysql/data
 chown -R mysql.mysql /application/mysql
 /application/mysql/scripts/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data/ --user=mysql
 tree /application/mysql/data/

6.2.4 configuration and start the MySQL database

1) Set the MySQL startup script

cp support-files/mysql.server /etc/init.d/mysqld  #拷贝MySQL启动脚本到MySQL的命令路径
chmod +x /etc/init.d/mysqld #使脚本可执行

2) Replace the binary default installation path

sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /etc/init.d/mysqld
#MySQL二进制默认安装路径是/usr/local/mysql ,启动脚本里是/usr/local/mysql 的路径都需要替换

3) Start the MySQL database

/etc/init.d/mysqld start

4) Check the MySQL database whether to start

netstat -lntup|grep mysql   #查看3306端口

5) Check out the MySQL database log results start

tail -100 /application/mysql/data/www.oldboy.top.err #如果3306没启动,查看日志文件

6) Set MySQL boot

chkconfig --add mysqld
chkconfig mysqld on
chkconfig --list mysqld

7) the use of global configuration commands mysql path

echo 'export PATH=$PATH:/application/mysql/bin' >>/etc/profile
tail -1 /etc/profile
yum install -y source
source /etc/profile

Global Settings encountered inappropriate circumstances, can only be used to profile winscp copy out modifications.
Global Path problems due to improper settings can look at the following links https://blog.51cto.com/oldboy/1122867

8) Log MySQL test

mysql
show databases;
select user();

6.2.5 MySQL Security Configuration

1) Configure the password for the root user of MySQL

mysqladmin -u root password 'oldboy123' #更改默认密码
mysql -uroot -p
mysql -uroot -p'oldboy123'

2) clean up unwanted MySqL users and libraries

mysql> select user,host from mysql.user;
mysql> drop user ""@"www.oldboy.top";
mysql> drop user "root"@"www.oldboy.top";
mysql> drop user ""@"localhost";
mysql> show databases;
mysql> drop database test;



Guess you like

Origin www.cnblogs.com/wadelin/p/12073722.html