Centos7 deploying mysql-5.7

User 1348170 2022-06-24 06:33:54 阅读数:565

centos7centosdeployingmysql-5.7mysql

One . Environmental statement

[mysql-Server] Host name = host-1 System = centos-7.3 Address = 1.1.1.1 Software = mysql-5.7 3306

Using binary package deployment will result in large downloads , about 500M about , There are dozens of source code packages M. But using binary packages does not require compilation , Faster deployment , Compared with yum You can customize the directory , Convenient maintenance .

Two . Program deployment

1. Installation dependency yum -y install autoconf libaio bison ncurses-devel

2. Create user groupadd mysqluseradd -g mysql -s /sbin/nologin mysql

3. clear centos7 The default built-in database , Be sure to clean it up yum -y remove mariadb mariadb-server

4. Download binary package wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.21-linux-glibc2.12-x86_64.tar.gztar -xf mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz

Move past , Next is the storage path mv mysql-5.7.21-linux-glibc2.12-x86_64 /usr/local/mysqlmkdir /var/log/mysqlmkdir /usr/local/mysql/data

mysql Even if root Start or mysql user-run , So give permission chown -R mysql:mysql /usr/local/mysqlchown -R mysql:mysql /var/log/mysql

5. Go in and delete all rows , Add new vim /etc/my.cnf

[client]port = 3306socket = /tmp/mysql.sock[mysqld]character_set_server=utf8init_connect='SET NAMES utf8'basedir=/usr/local/mysqldatadir=/usr/local/mysql/datasocket=/tmp/mysql.socklog-error=/var/log/mysqld.logpid-file=/usr/local/mysql/mysqld.pid

6. initialization cd /usr/local/mysql/bin

Initialize database , No response is correct , Here you can customize the directory /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --lc_messages_dir=/usr/local/mysql/share --lc_messages=en_US

7. Join in systemctl control vim /usr/lib/systemd/system/mysql.service

[Unit]Description=mysqlAfter=network.target remote-fs.target nss-lookup.target[Service]Type=forkingExecStart=/usr/local/mysql/support-files/mysql.server startExecReload=/usr/local/mysql/support-files/mysql.server restartExecStop=/usr/local/mysql/support-files/mysql.server stopPrivateTmp=true[Install]WantedBy=multi-user.target

8. Set the environment variable echo 'PATH=$PATH':/usr/local/mysql/bin >> /etc/profilesource /etc/profile

9. start-up systemctl daemon-reloadsystemctl start mysqlsystemctl enable mysql

3、 ... and . Change initial password 1. Check the password cat /var/log/mysqld.log The last line :[email protected]: Here is the initial password

You need to enter the database and change the password with the following command to make the database work normally mysql -uroot -pALTER USER USER() IDENTIFIED BY '123456';

copyright:author[User 1348170],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/175/20210714191125891b.html