mysql5.7 binary packages installed

Tsinghua download mysql.tar.gz a source installation package uploaded to the linux server directory / usr / local
 https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.7/mysql-5.7.27-linux x86_64.tar.gz--glibc2.12  --- Tsinghua the mirror

https://dev.mysql.com/downloads/file/?id=474755  --- MySQL official website

Two entering / usr / local directory and rename extracting installation package
CD / usr / local
the tar--zxvf MySQL 5.7.27-Linux-glibc2.12-x86_64.tar.gz
Music Videos-MySQL 5.7.27-Linux-glibc2.12- MySQL the x86_64
CD MySQL 
mkdir Data

Three groups of users to create mysql, mysql create a user and add it to the mysql user group, and give read and write permissions
groupadd mysql - create mysql user group group
useradd -r -g mysql mysql - mysql user created and added to the mysql
chown -R mysql mysql - mysql directory will assign access rights to users myql
chgrp -R mysql mysql / - change mysql directory user group belongs to the group mysql

四 创建配置文件 保存并退出
vim /etc/my.cnf
[client]
port = 3306
socket = /usr/local/mysql/data/mysql.sock
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/data/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
#不区分大小写
lower_case_table_names = 1
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
max_connections=5000
default-time_zone = '+8:00'
expire_logs_days=7

Copy the startup scripts, and modify its properties
cp Support-Files / mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
modify the startup script: vim /etc/init.d/mysqld
basedir = / usr / local / MySQL
DATADIR = / usr / local / MySQL / Data

Finally, the addition of msyql environment variable
 to open the file vim / etc / profile
rearmost add export PATH = / usr / local / mysql / bin: $ PATH
After saving a good source / etc / profile

Five initialize the database
# first install about this stuff, or else there may be error initialization, initialization fails then install
yum install libaio
# manually edit your log file, do not write anything, save to exit
cd / var / log /
vim mysqld .log
: WQ

chmod 777 mysqld.log
chown mysql:mysql mysqld.log

/usr/local/mysql/bin/mysqld   --initialize --user=mysql   --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data


View six initial password
cat /var/log/mysqld.log
passwords down
the last line: root @ localhost: this is the initial password


Seven to start the service, enter MySQL
cd / var / RUN /
mkdir mysqld
chmod 777 mysqld
cd mysqld
vim mysqld.pid
: WQ
chmod 777 mysqld.pid
chown MySQL: MySQL mysqld.pid

service mysqld start

 

Precautions:

Login failed to change the password:

we /etc/my.cnf

Add a line:   Skip-Grant-the Tables 

Save and exit: wq

Restart mysql service: Service Start mysqld

 

After initialization landing database, change password:
SET password = password ( 'A1B2C3 #. 4');
SET password = password ( 'MySQL @ 123');
Update User SET authentication_string = password ( 'MySQL @ 123'), Host = '% 'WHERE User =' the root ';
Update the mysql.user SET authentication_string = password (' @ 123 MySQL ') WHERE User =' the root ';

 

New user
create user 'bm2016' @ 'localhost ' identified by 'app_ QAZxsw2!';
User to add remote access to
GRANT ALL PRIVILEGES ON * * the TO 'repl' @ '%' IDENTIFIED BY '' the WITH GRANT OPTION;.
Grant All privileges . * * to ON 'bm2016' @ 'localhost' IDENTIFIED by 'app_ QAZxsw2!';
flush privileges;

发布了9 篇原创文章 · 获赞 1 · 访问量 228

Guess you like

Origin blog.csdn.net/weixin_43857096/article/details/103969234