本篇内容主要讲解“CentOS7.4环境下怎么用源码安装Mysql 5.7.26”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“CentOS7.4环境下怎么用源码安装Mysql 5.7.26”吧!
yum -y install gcc gcc-c++ ncurses ncurses-devel bison cmake make
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
tar -zxvf mysql-5.7.26.tar.gz
进入解压后的目录,为了保持源码干净,新建子目录 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 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
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
(1) 3306
1 |
|
(2) 3307
1 |
|
( 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 &
[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 &
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
到此,相信大家对“CentOS7.4环境下怎么用源码安装Mysql 5.7.26”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。