欢迎来到阿里云授权服务中心典名科技有限公司!咨询电话:023-66887777 18623333330

微信
手机版
网站地图

mysql的源码安装方法

2021-08-23 10:29:30 投稿人 : admin 围观 : 133 次 0 评论

本篇内容介绍了“mysql的源码安装方法”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

image.png

环境
centos6.7
mysql5.7.12        

一、centos 配置yum
修改centos参数
[root@centos yum.repos.d]# cat CentOS-Media.repo
# CentOS-Media.repo
#  yum --disablerepo=\* --enablerepo=c6-media [command] 
[c6-media]
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS/
        file:///media/cdrom/
        file:///media/cdrecorder/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

---修改参数文件名字
[root@centos yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak

[root@centos yum.repos.d]# mkdir /media/cdrom
[root@centos yum.repos.d]# mount /dev/cdrom /media/cdrom
[root@centos yum.repos.d]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_centos-lv_root
                       18G  4.9G   12G  30% /
tmpfs                 877M   68K  877M   1% /dev/shm
/dev/sda1             477M   37M  416M   9% /boot
/dev/sr0              3.7G  3.7G     0 100% /media/cdrom

[root@centos cdrom]# yum repolist
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * c6-media: 
repo id                                          repo name                                                 status
c6-media                                         CentOS-6 - Media                                          6,575
repolist: 6,575
[root@centos cdrom]# 

二、安装gcc和cmake
[root@centos soft]# yum -y install gcc*
[root@centos ~]# gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[root@centos cmake-3.5.2]# ./configure
[root@centos cmake-3.5.2]# make
[root@centos cmake-3.5.2]# make install
[root@centos cmake-3.5.2]# cmake --version
cmake version 3.5.2
CMake suite maintained and supported by Kitware (kitware.com/cmake).
[root@centos cmake-3.5.2]# cd ..

三、添加用户组,并编译mysql软件
[root@centos cmake-3.5.2]# 
[root@centos cmake-3.5.2]# groupadd mysql
[root@centos cmake-3.5.2]# useradd -g mysql mysql
[root@centos cmake-3.5.2]# id mysql
uid=500(mysql) gid=500(mysql) groups=500(mysql)
[root@centos cmake-3.5.2]# 
[root@centos cmake-3.5.2]# 
cmake . -DCMAKE_INSTALL_PREFIX=/soft/mysql -DMYSQL_DATADIR=/soft/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -
DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/soft/soft/mysql-5.7.12/boost
安装编译mysql需要的包
[root@centos Packages]# yum -y install ncurses*
[root@centos mysql-5.7.12]# cmake . -DCMAKE_INSTALL_PREFIX=/soft/mysql -DMYSQL_DATADIR=/soft/data -DDEFAULT_CHARSET=utf8 -
DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/soft/soft/mysql-
5.7.12/boost
[root@centos mysql-5.7.12]# 
[root@centos mysql-5.7.12]# make
Scanning dependencies of target abi_check
[  0%] Built target abi_check
.o
[100%] Linking CXX executable my_safe_process
[100%] Built target my_safe_process
[root@centos mysql-5.7.12]# 
[root@centos mysql-5.7.12]# 
[root@centos mysql-5.7.12]# 
[root@centos mysql-5.7.12]# 
[root@centos mysql-5.7.12]# make install
[  0%] Built target abi_check
[  0%] Built target INFO_SRC
[  0%] Built target INFO_BIN
[  0%] Built target zlib
[  1%] Built target yassl

注意事项:
重新编译时,需要清除旧的对象文件和缓存信息。
# make clean
# rm -f CMakeCache.txt
# rm -rf /etc/my.cnf

四、初始化mysql数据库
创建目录并修改权限
[root@centos soft]# chown -R root.mysql mysql
[root@centos soft]# chown -R mysql.mysql data
[root@centos soft]# 
[root@centos soft]# 
拷贝mysql参数文件
[root@centos support-files]# cp my-default.cnf /etc/my.cnf
[root@centos support-files]# pwd
/soft/mysql/support-files
拷贝mysql控制文件
[root@centos support-files]# cp mysql.server /etc/init.d/mysql
[root@centos support-files]# 
---初始化mysql,datadir目录必须为空,这个版本的mysql可以使用mysqld来初始化mysql
[root@centos bin]# ./mysqld --user=mysql --datadir=/soft/data --initialize
2016-05-17T04:40:23.549193Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --
explicit_defaults_for_timestamp server option (see documentation for more details).
2016-05-17T04:40:23.549253Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used 
with strict mode. They will be merged with strict mode in a future release.
2016-05-17T04:40:23.549260Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2016-05-17T04:40:23.939423Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-05-17T04:40:24.004248Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-05-17T04:40:24.064255Z 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: 7847398f-1be9-11e6-9461-080027604fd8.
2016-05-17T04:40:24.066031Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2016-05-17T04:40:24.066944Z 1 [Note] A temporary password is generated for root@localhost: h(U-s2(RhCG*
[root@centos bin]# 

五、修改mysql的root密码
[root@centos data]# service mysql stop
Shutting down MySQL.[  OK  ]
[root@centos data]# 
[root@centos ~]# mysqld_safe --skip-grant-tables&
[1] 18383
[root@centos ~]# 2016-05-17T04:45:34.890822Z mysqld_safe Logging to '/soft/data/centos.err'.
2016-05-17T04:45:34.914605Z mysqld_safe Starting mysqld daemon with databases from /soft/data
[root@centos ~]# 
[root@centos ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.12 Source distribution
Copyright (c) 2000, 2016, 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> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set authentication_string=PASSWORD("root") where user='root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> 
[root@centos ~]# service mysql stop
Shutting down MySQL..2016-05-17T04:48:57.945185Z mysqld_safe mysqld from pid file /soft/data/centos.pid ended
[  OK  ]
[1]+  Done                    mysqld_safe --skip-grant-tables
[root@centos ~]# 
[root@centos ~]# 
[root@centos ~]# 
[root@centos ~]# 
[root@centos ~]# service mysql start
Starting MySQL.[  OK  ]
[root@centos ~]# 

---这个版本的mysql的root密码需要重新设置
[root@centos ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.12
Copyright (c) 2000, 2016, 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> 
mysql> use mysql
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> 
mysql> set password='root';
Query OK, 0 rows affected (0.00 sec)
mysql> 
mysql> 
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> 
mysql> 

版权声明:本站部分文章内容、图片来源于网友推荐、互联网收集整理而来,仅供大家学习参考,不代表本站立场,如有侵权,请联系站长,我们会第一时间处理!本站原创内容未经允许不得转载,或转载时需注明出处:典名科技资讯门户

相关文章

  • oracle临时表空间的增删改查命令
    oracle临时表空间的增删改查命令

    oracle临时表空间的增删改查命令发布时间:2021-08-31 01:57:42来源:阿里云阅读:60作者:chen栏目:关系型数据库本篇内容介绍了“oracle临时表空间的增删改查命令”的有关知识,在实际案例的操作过程中,不少人都会遇...

    2021-08-31 11:52:19
  • Redis4.0从库复制报错"master_link_status:down"怎么处理
    Redis4.0从库复制报错"master_link_status:down"怎么处理

    “Redis4.0从库复制报错"master_link_status:down"怎么处理”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Redis4.0从库复制报错&quo...

    2021-08-31 11:52:19
  • MySQL数据库中有哪些锁
    MySQL数据库中有哪些锁

    “MySQL数据库中有哪些锁”,在日常操作中,相信很多人在MySQL数据库中有哪些锁问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”MySQL数据库中有哪些锁”的疑惑有所帮助!接下来!在 MySQL 数据库中,...

    2021-08-31 11:24:19
  • MSSQL报错参数数据类型text对于replace函数的参数1无效怎么解决
    MSSQL报错参数数据类型text对于replace函数的参数1无效怎么解决

    “MSSQL报错参数数据类型text对于replace函数的参数1无效怎么解决”,在日常操作中,相信很多人在MSSQL报错参数数据类型text对于replace函数的参数1无效怎么解决问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作...

    2021-08-31 11:21:19
  • solaris11 ssh怎么禁止root用户连接
    solaris11 ssh怎么禁止root用户连接

    “solaris11 ssh怎么禁止root用户连接”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“solaris11 ssh怎么禁止root用户连接”吧!在虚拟机中新安装的solaris11,安...

    2021-08-31 11:20:19
  • 怎么用SQL语句查看SQL Server的结构信息
    怎么用SQL语句查看SQL Server的结构信息

    “怎么用SQL语句查看SQL Server的结构信息”,在日常操作中,相信很多人在怎么用SQL语句查看SQL Server的结构信息问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”怎么用SQL语句查看SQL S...

    2021-08-31 11:04:20
  • sqlplus和sqlldr工具的安装方法
    sqlplus和sqlldr工具的安装方法

    “sqlplus和sqlldr工具的安装方法”。本文介绍的方法操作简单快捷,实用性强。sqlplus和sqlldr工具的安装方法”吧!不管安装什么客户端工具都需要先安装instantclient-basic-linux.x64-11.2.0...

    2021-08-31 10:59:20
  • MHA的安装和部署步骤
    MHA的安装和部署步骤

    “MHA的安装和部署步骤”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!##################MHA安装和部署###########...

    2021-08-31 10:52:20
  • redis4.0下MEMORY命令详解
    redis4.0下MEMORY命令详解

    “redis4.0下MEMORY命令详解”,在日常操作中,相信很多人在redis4.0下MEMORY命令详解问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”redis4.0下MEMORY命令详解”的疑惑有所帮助...

    2021-08-31 10:52:19
  • MySQL内存线程独享使用的方法
    MySQL内存线程独享使用的方法

    “MySQL内存线程独享使用的方法”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“MySQL内存线程独享使用的方法”吧!  今天这篇文章暂时先分析 MySQL 中主要的 “线程独享内存” 的。...

    2021-08-25 10:37:36
发表评论