设为首页 收藏本站
查看: 665|回复: 0

[经验分享] centos下mysql 5源码安装全过程记录

[复制链接]

尚未签到

发表于 2017-11-23 06:41:14 | 显示全部楼层 |阅读模式
  参考:http://blog.csdn.net/mycwq/article/details/24488691

  • 安装cmake,mysql 5.5以后的版本要通过cmake进行编译
  在新装的CentOS 5.7系统中,先安装了nginx(含nginx必备依赖:gzip 模块需要 zlib 库;rewrite 模块需要 pcre 库;ssl 功能需要 openssl 库),结果安装cmake过程中在./bootstrap这一步无法通过,原因未知。后通过VM快照恢复到未安装nginx前,顺利安装cmake。
  安装步骤:

  • 官网下载http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz
  • tar zxvf cmake-2.8.10.2.tar.gz
  • cd cmake-2.8.10.2
  • ./bootstrap
  • make
  • make install
  • cmake –h      验证安装结果

  • 开始安装mysql
  官网下载源码安装包:https://cdn.mysql.com//Downloads/MySQL-5.5/mysql-5.5.57.tar.gz
  安装mysql


  • [iyunv@local ~]# wget http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.37.tar.gz
  • [iyunv@local ~]# tar xvf mysql-5.5.37.tar.gz
  • [iyunv@local ~]# cd mysql-5.5.37
  • [iyunv@local mysql-5.5.37]# cmake ./
  可能还会报这个错,没有就跳过


  • CMake Error at cmake/readline.cmake:83(MESSAGE):
  • Curses library not found.  Pleaseinstall appropriate package,
  • remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name islibncurses5-dev, on Redhat and derivates it is ncurses-devel.
  • Call Stack (most recent call first):
  • cmake/readline.cmake:127 (FIND_CURSES)
  • cmake/readline.cmake:217 (MYSQL_USE_BUNDLED_LIBEDIT)
  • CMakeLists.txt:355 (MYSQL_CHECK_READLINE
  • -- Configuring incomplete, errors occurred!
  • See also "/root/my/mysql-5.5.37/CMakeFiles/CMakeOutput.log".
  • See also"/root/my/mysql-5.5.37/CMakeFiles/CMakeError.log".
  说明centos系统没有ncurses-devel


  • [iyunv@local ~]# wget http://invisible-island.net/datafiles/release/ncurses.tar.gz
  • [iyunv@local ~]# cd ncurses-5.9
  • [iyunv@local ncurses-5.9]#./configure
  • [iyunv@local ncurses-5.9]# make
  • [iyunv@local ncurses-5.9]# make install
  再删除刚才编译生成的 CMakeCache.txt 文件,否则无法进行下一步


  • [iyunv@local mysql-5.5.37]# rm -f CMakeCache.txt
  继续编译mysql


  • [iyunv@local ~]# cmake ./
  • [iyunv@local ~]# make
  • [iyunv@local ~]# make install
  这样,mysql默认将成功安装到/usr/local/mysql
  创建mysql用户组


  • [iyunv@local ~]# groupadd mysql
  • [iyunv@local ~]# useradd –r –g mysql mysql
  • [iyunv@local ~]# chown –R mysql.mysql /usr/local/mysql
  
启动mysql


  • [iyunv@local ~]# /usr/local/mysql/bin/mysqld_safe --user=mysql
  这里可能会发生错误,没有就跳过:


  • FATAL ERROR: Could not find./bin/my_print_defaults
  • If you compiled from source, you need torun 'make install' to
  • copy the software into the correct locationready for operation.
  • If you are using a binary release, you musteither be at the top
  • level of the extracted archive, or pass the --basedir option
  • pointing to that location.
  解决方法:


  • [iyunv@local ~]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
  再启动mysql


  • [iyunv@local ~]# /usr/local/mysql/bin/mysqld_safe --user=mysql
  注册mysql服务,开机自动启动
  1.设置mysql配置文件到/etc目录


  • [iyunv@local ~]# cp /usr/local/mysql/support-files/my-medium.cnf/etc/my.cnf
  2.设置mysql开机自启


  • [iyunv@local ~]# cp/usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
  • [iyunv@local ~]# chmod +x /etc/init.d/mysql
  • [iyunv@local ~]# /sbin/chkconfig --add mysql
  3.启动mysql服务


  • [iyunv@local ~]# service mysql start
  测试mysql是否安装成功


  • [iyunv@local ~]# /usr/local/mysql/bin/mysql -u root -p
  • Enter password:
  • Welcome to the MySQL monitor.  Commands end with ; or \g.
  • Your MySQL connection id is 1
  • Server version: 5.5.37 Source distribution

  • Copyright (c) 2000, 2014, Oracle and/or itsaffiliates. All rights reserved.

  • Oracle is a registered trademark of OracleCorporation and/or its
  • affiliates. Other names may be trademarksof their respective
  • owners.

  • Type 'help;' or '\h' for help. Type '\c' toclear the current input statement.

  • mysql> show databases;
  • +--------------------+
  • | Database           |
  • +--------------------+
  • | information_schema |
  • | mysql              |
  • | performance_schema |
  • | test               |
  • +--------------------+
  • 4 rows in set (0.03 sec)
  参考:
  http://blog.csdn.net/mycwq/article/details/24488691
  最后启动mysql的时候报错,出现The serverquit without updating PID file错误
  解决过程:http://blog.sina.com.cn/s/blog_637e04c9010117ri.html
[iyunv@localhost ~]# cd/usr/local/mysql

[iyunv@localhost mysql]# chown-R mysql.mysql .
[iyunv@localhost mysql]# su - mysql
[mysql@localhost ~]$ cd/usr/local/mysql
[mysql@localhost mysql]$ scripts/mysql_install_db
Installing MySQL system tables...
OK
Filling help tables...
OK

  To start mysqld at boot time youhave to copy
support-files/mysql.server to the right place for your system
  PLEASE REMEMBER TO SET A PASSWORDFOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
  ./bin/mysqladmin -u root password'new-password'
./bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
  Alternatively you can run:
./bin/mysql_secure_installation
  which will also give you the optionof removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
  See the manual for moreinstructions.
  You can start the MySQL daemonwith:
cd . ; ./bin/mysqld_safe &
  You can test the MySQL daemon withmysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl
  Please report any problems with the./bin/mysqlbug script!
[mysql@localhost mysql]$ /usr/local/mysql/bin/mysqld_safe--user=mysql &
[1] 11767
[mysql@localhost mysql]$ 120502 07:01:17 mysqld_safe Logging to'/usr/local/mysql/data/localhost.localdomain.err'.
120502 07:01:17 mysqld_safe Starting mysqld daemon with databases from/usr/local/mysql/data
[mysql@localhost mysql]$ /etc/rc.d/init.d/mysql status
MySQL running(11830)                                     [  OK  ]
[mysql@localhost mysql]$ /etc/rc.d/init.d/mysql start
StartingMySQL                                             [  OK  ]

  最后这里↗$ /etc/rc.d/init.d/mysqlstart可能需要切回root用户才能成功启动
  额外配置
  如果非本地环境无法登陆mysql,做如下更改
  1.Centos中防火墙开放3306端口:
  -A INPUT -p tcp-m tcp --dport 3306 -j ACCEPT
  2.Mysql中允许root用户任意IP登陆:
  Update user sethost=”%” where user=”root”;
  3. mysql取消表名区分大小写
  修改 /etc/my.cnf:在[mysqld]节点下,加入一行: lower_case_table_names=1
  4.使用mysql-workbench工具导入.sql文件

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-409712-1-1.html 上篇帖子: Yoooshiki 下篇帖子: Ansible Playbooks基本使用
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表