CentOS7.4环境下怎么用源码安装Mysql5.7.26-创新互联
本篇内容主要讲解“CentOS7.4环境下怎么用源码安装Mysql 5.7.26”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“CentOS7.4环境下怎么用源码安装Mysql 5.7.26”吧!
成都创新互联公司专注于二道江企业网站建设,响应式网站设计,成都做商城网站。二道江网站建设公司,为二道江等地区提供建站服务。全流程定制设计,专业设计,全程项目跟踪,成都创新互联公司专业和态度为您提供的服务一、软件安装
1. 安装必要的软件依赖
yum -y install gcc gcc-c++ ncurses ncurses-devel bison cmake make
2、下载mysql源码包
mkdir /software cd /software wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.26.tar.gz
查看下载包:
[root@localhost software]# ls mysql-5.7.26.tar.gz
3、解压mysql源码包
tar -zxvf mysql-5.7.26.tar.gz
3、配置编译mysql源码包
进入解压后的目录,为了保持源码干净,新建子目录 yunxiaochong,在子目录下编译
[root@localhost software]# ls mysql-5.7.26 mysql-5.7.26.tar.gz [root@localhost software]# cd mysql-5.7.26/ [root@localhost mysql-5.7.26]# mkdir yunxiaochong [root@localhost mysql-5.7.26]# cd yunxiaochong/
cmake配置:
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DWITH_READLINE=1 \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DEXTRA_CHARSETS=all \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_SSL=bundled \ -DDOWNLOAD_BOOST=1 \ -DWITH_BOOST=/tmp
注:
如果编译出现错误,请先删除CMakeCache.txt后,再重新编译:
rm -rf CMakeCache.txt
如果出现下面的提示就表示成功生成了编译环境:
-- Configuring done
-- Generating done
编译:
make -j 10
安装:
make instal
二、数据库安装
1、创建用户
1 2 |
|
2、创建目录,并修改目录属主和添加环境变量
mkdir -p /data/mysql/{3306,3307}/{data,log}
chown -R mysql:mysql /data/mysql/ chown -R mysql:mysql /usr/local/mysql/
echo 'export PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile source /etc/profile
3、创建配置文件
3306
vim /data/mysql/3306/my3306.cnf
内容如下:
[mysqld] basedir=/usr/local/mysql datadir=/data/mysql/3306/data port=3306 socket=/data/mysql/3306/mysql3306.sock character-set-server=utf8 log-error=/data/mysql/3306/log/error3306.log pid-file=/data/mysql/3306/mysqld3306.pid
3307
vim /data/mysql/3307/my3307.cnf
内容如下:
[mysqld] basedir=/usr/local/mysql datadir=/data/mysql/3307/data port=3307 socket=/data/mysql/3307/mysql3307.sock character-set-server=utf8 log-error=/data/mysql/3307/log/error3307.log pid-file=/data/mysql/3307/mysqld3307.pid
4、数据库初始化
(1) 3306
1 |
|
(2) 3307
1 |
|
5、数据库启动
( 1) 3306
cd /usr/local/mysql/bin ./mysqld_safe --defaults-file=/data/mysql/3306/my3306.cnf --user=mysql &
(2)3307
cd /usr/local/mysql/bin ./mysqld_safe --defaults-file=/data/mysql/3307/my3307.cnf --user=mysql &
6、获取初始密码
[root@localhost bin]# less /data/mysql/3307/log/error3307.log|grep 'A temporary password'
2019-07-22T02:04:41.482707Z 1 [Note] A temporary password is generated for root@localhost: Kjipuugr0:0v
登录报错:
[mysql@localhost ~]$ mysql -uroot -P3306 -S /data/mysql/3307/mysql3307.sock -p
Enter password:
ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supports expired passwords.
解决方法:
(1)先关闭数据库实例,由于不能登录,所以只能有kill -9 执行杀掉进程。
(2)再配置文件中,添加选项
skip-grant-tables
(3)重启数据库实例
(4)免密码登录:
mysql -uroot -P3306 -S /data/mysql/3306/mysql3306.sock
(5.1)修改密码过期策略:
MySQL [none]>use mysql MySQL [mysql]> update user set password_expired='N' where user='root'; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0
(5.2)修改密码:
MySQL [none]>use mysql MySQL [mysql]> update user set authentication_string = password("Yxc@3306") where user="root" ; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0
(6)重启数据库实例
[mysql@localhost ~]$ mysqladmin -uroot -S /data/mysql/3306/mysql3306.sock shutdown cd /usr/local/mysql/bin
./mysqld_safe --defaults-file=/data/mysql/3306/my3306.cnf --user=mysql &
7、创建用户
MySQL [(none)]> create USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Yxc3307'; Query OK, 0 rows affected (0.00 sec) MySQL [(none)]> grant all privileges on *.* to 'root'@'%'; Query OK, 0 rows affected (0.00 sec)
说明:
MySQL8.0之前的版本密码加密规则:mysql_native_password,
MySQL8.0密码加密规则:caching_sha2_password
8、navicat 登录
到此,相信大家对“CentOS7.4环境下怎么用源码安装Mysql 5.7.26”有了更深的了解,不妨来实际操作一番吧!这里是创新互联网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
网页名称:CentOS7.4环境下怎么用源码安装Mysql5.7.26-创新互联
转载来于:http://cdiso.cn/article/dhiodp.html