1.yum/rpm安装
2.采用二进制方式免编译安装MySQL。
3.考虑到MySQL5.4.xx及以后系列产品的特殊性,其编译方式和早期的第一条产品线的有所不同,这里采用cmake或gmake方式的编译安装。即./cmake;make;make install
4.常规方式编译安装MySQL时,适合用第一条最正宗的MySQL产品线5.2及以前版本:所谓常规方式编译安装MySQL就是延续早期MySQL的3部曲安装方式,即./configure;make;make install
 
一、实验环境 
环境:CentOS6.5
软件:mysql-5.5.32-linux2.6-x86_64
 
二、实验步骤 
二进制包安装mysql数据库,二进制安装无需编译,即直接解压放置安装的目录即可
 
1)二进制安装mysql5.5.32-linux2.6-x86_64.tar.gz ,解压。
tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz
 
mv mysql-5.5.32-linux2.6-x86_64 /application/mysql
 
2)创建mysql用户  
useradd mysql -s /sbin/nologin/ -M
 
3)授权/application/mysql
chown -R mysql.mysql /application/mysql
 
4)初始化数据库
cd /application/mysql
 
mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/application/mysql --datadir=/application/mysql/data/
WARNING: The host 'lnmp01' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
160609 22:14:24 [Note] /application/mysql/bin/mysqld (mysqld 5.5.49) starting as process 10430 ...
ERROR: 1005  Can't create table 'tmp_db' (errno: 13)
160609 22:14:24 [ERROR] Aborting
 
160609 22:14:24 [Note] /application/mysql/bin/mysqld: Shutdown complete
 
 
Installation of system tables failed!  Examine the logs in
/application/mysql/data/ for more information.
 
You can try to start the mysqld daemon with:
 
    shell> /application/mysql/bin/mysqld --skip-grant &
 
and use the command line tool /application/mysql/bin/mysql
to connect to the mysql database and look at the grant tables:
 
    shell> /application/mysql/bin/mysql -u root mysql
    mysql> show tables
 
Try 'mysqld --help' if you have problems with paths.  Using --log
gives you a log in /application/mysql/data/ that may be helpful.
 
Please consult the MySQL manual section
'Problems running mysql_install_db', and the manual section that
describes problems on your OS.  Another information source are the
MySQL email archives available at http://lists.mysql.com/.
 
Please check all of the above before submitting a bug report
at http://bugs.mysql.com/
 
如出现上诉错误,原因是mysql无法向/tmp/目录写入'tmp_db',解决方法:给/tmp目录授权:chown -R mysql.mysql /tmp/,再次初始化即可。   
 
Installing MySQL system tables...
160610  0:36:37 [Note] /application/mysql//bin/mysqld (mysqld 5.5.49) starting as process 11463 ...
OK
Filling help tables...
160610  0:36:37 [Note] /application/mysql//bin/mysqld (mysqld 5.5.49) starting as process 11470 ...
OK
 
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
 
出现两个OK代表mysql数据库安装成功。
 
 
5)生成配置文件    
\cp /application/mysql/support-files/mysql-small.cnf /etc/my.cnf  
 
6)配置启动mysql    
sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe
 
/application/mysql/bin/mysqld_safe & 后台启动mysql    
 
7)写入环境变量  
vi /etc/profile
 
PATH="/application/mysql/bin:$PATH"
 
source /etc/profile  
 
或者
root@lnmp01 application]# cp /application/mysql/bin/* /usr/local/sbin/
[root@lnmp01 application]# which mysql
/usr/local/sbin/mysql
 
8)修改启动方法
 
cp support-files/mysql.server /etc/init.d/mysqld
 
 sed -i 's#/usr/local/mysql#/application/mysql#g' /etc/init.d/mysqld
 
 chmod +x /etc/init.d/mysqld
 
 chkconfig mysqld on  
 
 /etc/init.d/mysqld start
 
9.登录mysql   
[root@lnmp01 application]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.49 MySQL Community Server (GPL)
 
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>
 
 
10.设置密码和更改密码
/application/mysql/bin/mysqladmin -u root -password 'new-password'
/application/mysql//bin/mysqladmin -u root -h lnmp01 password 'new-password'
 
mysqladmin -uroot password "chen"  ---设置密码
mysqladmin -uroot -pchen password "chen123"---修改密码

如何从零安装Mysql的更多相关文章

  1. 60分钟内从零起步驾驭Hive实战学习笔记(Ubuntu里安装mysql)

    本博文的主要内容是: 1. Hive本质解析 2. Hive安装实战 3. 使用Hive操作搜索引擎数据实战 SparkSQL前身是Shark,Shark强烈依赖于Hive.Spark原来没有做SQL ...

  2. CentOS 6.9上安装Mysql 5.7.18 安装

    CentOS 6.9上安装Mysql 5.7.18 安装 下载地址:https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.18-linux-g ...

  3. CentOS安装mysql、JDK、Tomcat部署环境

    1.1. 安装mysql-5.6 1.1.1. 检测系统内部有没有安装其他的mysql数据库 $ rpm -qa | grep mysql 1.1.2. 如果内部有需要先删除Mysql $ yum r ...

  4. Centos6.5下编译安装mysql 5.6

    一:卸载旧版本 使用下面的命令检查是否安装有MySQL Server rpm -qa | grep mysql 有的话通过下面的命令来卸载掉 rpm -e mysql //普通删除模式 rpm -e ...

  5. 在Ubuntu 16.10安装mysql workbench报未安装软件包 libpng12-0错误

    1.安装mysql workbench,提示未安装软件包 libpng12-0 下载了MySQL Workbench 6.3.8   在安装的时候报错: -1ubu1604-amd64.deb 提示: ...

  6. ubuntu安装mysql

    好记性不如烂笔头,记录一下,ubuntu安装mysql的指令. 安装MySQL: sudo apt-get install mysql-server sudo apt-get install mysq ...

  7. Linux1 在Linux(CentOS)上安装MySql详细记录

    前记:  毕业两年了,前两天换了份工作,由以前的传统行业跳到了互联网行业.之前的公司一直在用WinServer2003+Tomcat+SqlServer/Oracle这套部署环境.对于Linux+To ...

  8. PHP安装mysql.so扩展

    在PHP中mysql_connect模块已经逐渐被弃用,我在搭建环境时也没有再安装mysql扩展,但是今天在维护一个老项目时,出现报错 Fatal error: Uncaught Error: Cal ...

  9. 安装MySql for Visual Studio的坑

    阅读目录 问题描述 解决过程 解决方案 总结 回到顶部 问题描述 安装MySql for Visual Studio 一般来说是为了能在VS的服务器数据连接的数据源中能选择MySql类型,如下图: 但 ...

随机推荐

  1. Go语言学习之2 包、函数、常量、数据类型、字符操作

    第一部分:基本数据类型和操作符 1. 文件名&关键字&标识符 (1)所有go源码以.go结尾    (2)标识符以字母或下划线开头,大小写敏感,比如: a. boy     b. Bo ...

  2. 雷林鹏分享:XML 注意事项

    XML 注意事项 这里列出了您在使用 XML 时应该尽量避免使用的技术. Internet Explorer - XML 数据岛 它是什么?XML 数据岛是嵌入到 HTML 页面中的 XML 数据. ...

  3. java日志及异常错误信息输出的问题

    1.异常信息可以层层传递,直到最后一层再输出日志也来得及 2.错误信息要在发生错误的当时就输出日志,否则到了其它层,很难得到准确的错误信息内容

  4. apicloud 按返回键

    api.addEventListener({ name: 'keyback' }, function(ret, err) { //调取index.html暴露的方法 api.execScript({ ...

  5. 自定义session的存储机制

    <?php class MSession implements SessionHandlerInterface{ // reids 对象 protected $handler = null; / ...

  6. Codefores 1151E Number of Components

    大意:给定n元素序列$a$, $1\le a_i \le n$, 定义函数$f(l,r)$表示范围在$[l,r]$以内的数构成的连通块个数, 求$\sum\limits_{i=1}^{n}\sum\l ...

  7. 20165309 实验三 敏捷开发与XP实践

    2017-2018-2 20165309实验三<Java面向对象程序设计>实验报告 一.实验内容 1. XP基础 2. XP核心实践 3. 相关工具 二.实验步骤 (一)代码规范 1.在I ...

  8. Spring boot(六)优雅使用mybatis

    orm框架的本质是简化编程中操作数据库的编码,发展到现在基本上就剩两家了,一个是宣称可以不用写一句SQL的hibernate,一个是可以灵活调试动态sql的mybatis,两者各有特点,在企业级系统开 ...

  9. sonar-gerrit plugin配置

    配置 sonar-gerrit plugins stepspre-condition:1. Sonarqube(5.5及以上,本文使用的版本为6.1.3)关于如何安装配置Sonarqube,请参考其他 ...

  10. MySQL查询性能调优化

    一.索引的概念 索引:类似于字典的目录,设置索引可以 加速数据查找,对数据进行约束: 二.索引类型: 主键索引:保证数据唯一性,不能重复+不能为空 普通索引:加速数据查找 唯一索引:加速查找+不能重复 ...