码迷,mamicode.com
首页 > 数据库 > 详细

centos7 环境mysql5.7.28二级制部署安装

时间:2021-04-15 12:11:33      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:centos7   ati   修改   配置   localhost   ext   linux   root   file   

 

下载安装包:
wget  https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz

1)首先卸载mariadb,不然后面会和安装mysql需要的库冲突: [root@localhost ~]# rpm -qa | grep mariadb mariadb-libs-5.5.56-2.el7.x86_64 [root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
或者 yum -y remove
mariadb-libs-5.5.56-2.el7.x86_64
2)用root用户登录系统,增加mysql用户和组,数据库安装在此用户下:  
[root@localhost
~]# groupadd mysql
[root@localhost
~]# useradd -r -g mysql -s /bin/false mysql
3)准备数据目录 以/app/data为例,建议使用逻辑卷
[root@localhost
~]# mkdir -p /app/data
[root@localhost
~]# chown mysql.mysql /app/data/
[root@localhost
~]# chmod 750 /app/data
4)准备二进制文件:
[root@localhost
~]# tar xvf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
root@localhost
~]# cd /usr/local [root@localhost local]# ln -sv mysql-5.7.28-linux-glibc2.12-x86_64 mysql
‘mysql
-> ‘mysql-5.7.28-linux-glibc2.12-x86_64

 

初始化

[root@localhost mysql]#  cd /usr/local/mysql
[root@localhost mysql]#  bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/app/data
2021-04-14T07:09:51.566086Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-04-14T07:09:51.699185Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-04-14T07:09:51.741437Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-04-14T07:09:51.748439Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 6818fcf9-9cf0-11eb-b6f3-000c296ec98e.
2021-04-14T07:09:51.749109Z 0 [Warning] Gtid table is not ready to be used. Table mysql.gtid_executed cannot be opened.
2021-04-14T07:09:52.942597Z 0 [Warning] CA certificate ca.pem is self signed.
2021-04-14T07:09:53.148191Z 1 [Note] A temporary password is generated for root@localhost: ws+G)Y/#x4tr
[root@localhost mysql]# bin/mysql_ssl_rsa_setup
2021-04-14 00:10:16 [ERROR]   Failed to access directory pointed by --datadir. Please make sure that directory exists and is accessible by mysql_ssl_rsa_setup. Supplied value : /usr/local/mysql/data
[root@localhost mysql]# bin/mysql_ssl_rsa_setup --datadir=/app/data


添加配置文件:
[root@localhost mysql]# vim
/etc/my.cnf [mysqld] # GENERAL datadir=/app/data socket=/app/data/mysql.sock user=mysql default-storage-engine=InnoDB [mysqld_safe] log-error=/app/data/mysql-error.log pid-file=/app/data/mysqld.pid [client] cket=/app/data/mysql.sock

 

开启ssl连接

[root@localhost mysql]# bin/mysql_ssl_rsa_setup --datadir=/app/data
命令后面不加参数报错,加了--datadir后不报错

启动mysql进程:
[root@localhost mysql]# bin/mysqld_safe --user=mysql &
[1] 71484
[root@localhost mysql]# Logging to /app/data/mysql-error.log.
2021-04-14T07:11:09.377168Z mysqld_safe Starting mysqld daemon with databases from /app/data

[root@localhost mysql]# ps -ef|grep mysql
root      71484  70385  0 00:11 pts/2    00:00:00 /bin/sh bin/mysqld_safe --user=mysql
mysql     71629  71484  2 00:11 pts/2    00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/app/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/app/data/mysql-error.log --pid-file=/app/data/mysqld.pid --socket=/app/data/mysql.sock
root      71658  70385  0 00:11 pts/2    00:00:00 grep --color=auto mysql

 

 

设置开机启动:

[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysql.server 
[root@localhost mysql]#  chkconfig --add mysql.server

 

修改密码:

[root@localhost mysql]# /usr/local/mysql/bin/mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.28

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type help; or \h for help. Type \c to clear the current input statement.

mysql>  ALTER USER root@localhost IDENTIFIED WITH mysql_native_password BY root; 
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

 

远程连接授权:

[root@localhost mysql]# /usr/local/mysql/bin/mysql -uroot -proot
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.28 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type help; or \h for help. Type \c to clear the current input statement.

mysql> create user root@% identified with mysql_native_password by root;
Query OK, 0 rows affected (0.00 sec)

mysql> grant all privileges on *.* to root@% with grant option;
Query OK, 0 rows affected (0.00 sec)

mysql>  flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit

 

centos7 环境mysql5.7.28二级制部署安装

标签:centos7   ati   修改   配置   localhost   ext   linux   root   file   

原文地址:https://www.cnblogs.com/shanxia0812/p/14658325.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!