转载:http://lssrc.com/archives/385

环境:Ubuntu 13.04

数据库:MySQL 5.5.33

1.下载MySQL 5.5.33源码,地址http://dev.mysql.com/downloads/mysql/5.5.html#downloads

2.删除已安装过的MySQL

  1. carl@Carl-U:~$ sudo apt-get remove mysql*

3.添加用户组和用户

  1. carl@Carl-U:~$ sudo groupadd mysql
  2. carl@Carl-U:~$ sudo useradd -r -g mysql mysql

4.创建MySQL的安装目录

  1. carl@Carl-U:~$ sudo mkdir /usr/local/mysql

5.修改MySQL安装目录所有者

  1. carl@Carl-U:~$ sudo chown mysql:mysql /usr/local/mysql/

6.解压源码包

  1. carl@Carl-U:~$ sudo tar -zxvf mysql-5.5.33.tar.gz

7.进入 mysql-5.5.33目录内,因为在新版本的MySQL源码包中没有了configure,改用cmake方式编译。如果没有安装,先安装cmake

  1. carl@Carl-U:~$ sudo apt-get install cmake
  2. carl@Carl-U:~$ sudo apt-get install libncurses5-dev

注:ubuntu下安装libncurses5-dev;redhat下安装ncurses-devel
还需要其他程序

  1. carl@Carl-U:~$ sudo apt-get install g++
  2. carl@Carl-U:~$ sudo apt-get install bison
  3. carl@Carl-U:~$ sudo apt-get install libaio1

8.编译

  1. carl@Carl-U:~$ sudo cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
  2. -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock
  3. -DDEFAULT_CHARSET=utf8
  4. -DDEFAULT_COLLATION=utf8_general_ci
  5. -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk
  6. -DWITH_MYISAM_STORAGE_ENGINE=1
  7. -DWITH_INNOBASE_STORAGE_ENGINE=1
  8. -DWITH_MEMORY_STORAGE_ENGINE=1
  9. -DWITH_READLINE=1
  10. -DENABLED_LOCAL_INFILE=1
  11. -DMYSQL_DATADIR=/usr/local/mysql/data
  12. -DMYSQL_USER=mysql
  13. -DMYSQL_TCP_PORT=3306

编译结束后,出现下面的警告,不妨碍执行make

  1. ……
  2. – Generating done
  3. CMake Warning:
  4. Manually-specified variables were not used by the project:
  5. MYSQL_USER
  6. WITH_MEMORY_STORAGE_ENGINE
  7. – Build files have been written to: /home/carl/mysql-5.5.33

9.执行make和make install

  1. carl@Carl-U:~/mysql-5.5.33$ sudo make
  2. – Running cmake version 2.8.10.1
  3. – Looking for SHM_HUGETLB
  4. – Looking for SHM_HUGETLB - found
  5. – MySQL 5.5.33
  6. – Looking for sys/types.h
  7. – Looking for sys/types.h - found
  8. – Looking for stdint.h
  9. ……
  1. carl@Carl-U:~/mysql-5.5.33$ sudo make install
  2. [  0%] Built target INFO_BIN
  3. [  0%] Built target INFO_SRC
  4. [  0%] Built target abi_check
  5. [  2%] Built target zlib
  6. ……

10.从源码目录拷贝一些配置文件

  1. carl@Carl-U:~$ cd /home/carl/mysql-5.5.33/support-files/
  2. carl@Carl-U:~/mysql-5.5.33/support-files$ sudo cp my-medium.cnf /etc/my.cnf
  3. carl@Carl-U:~/mysql-5.5.33/support-files$ sudo cp mysql.server /etc/init.d/mysql

还要给/etc/init.d/mysql一个可执行的权限

  1. carl@Carl-U:~/mysql-5.5.33/support-files$ sudo chmod +x /etc/init.d/mysql

修改一下这个文件

  1. carl@Carl-U:~/mysql-5.5.33/support-files$ sudo vi /etc/init.d/mysql
  2. //修改内容
  3. basedir=/usr/local/mysql/
  4. datadir=/usr/local/mysql/data/

11.初始化数据库
进入MySQL安装后的目录

  1. carl@Carl-U:~/mysql-5.5.33$ cd /usr/local/mysql/
  2. carl@Carl-U:/usr/local/mysql$ sudo scripts/mysql_install_db –user=mysql –basedir=/usr/local/mysql/ –datadir=/usr/local/mysql/data

出现以下提示

  1. Installing MySQL system tables…
  2. OK
  3. Filling help tables…
  4. OK
  5. To start mysqld at boot time you have to copy
  6. support-files/mysql.server to the right place for your system
  7. PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
  8. To do so, start the server, then issue the following commands:
  9. /usr/local/mysql//bin/mysqladmin -u root password ’new-password’
  10. /usr/local/mysql//bin/mysqladmin -u root -h Carl-U password ’new-password’
  11. Alternatively you can run:
  12. /usr/local/mysql//bin/mysql_secure_installation
  13. which will also give you the option of removing the test
  14. databases and anonymous user created by default.  This is
  15. strongly recommended for production servers.
  16. See the manual for more instructions.
  17. You can start the MySQL daemon with:
  18. cd /usr/local/mysql/ ; /usr/local/mysql//bin/mysqld_safe &
  19. You can test the MySQL daemon with mysql-test-run.pl
  20. cd /usr/local/mysql//mysql-test ; perl mysql-test-run.pl
  21. Please report any problems with the /usr/local/mysql//scripts/mysqlbug script!

12.启动MySQL服务

  1. carl@Carl-U:/usr/local/mysql$ sudo /etc/init.d/mysql start
  2. Starting MySQL
  3. ….. *

13.修改数据库root用户的密码

  1. carl@Carl-U:~$ sudo /usr/local/mysql/bin/mysqladmin -u root password ’root’

13.登录
这时候直接输入mysql是找不到的
需要使用/usr/local/mysql/bin/mysql

  1. carl@Carl-U:~$ sudo /usr/local/mysql/bin/mysql -u root -p
  2. Enter password:
  3. Welcome to the MySQL monitor.  Commands end with ; or \g.
  4. Your MySQL connection id is 2
  5. Server version: 5.5.33-log Source distribution
  6. Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
  7. Oracle is a registered trademark of Oracle Corporation and/or its
  8. affiliates. Other names may be trademarks of their respective
  9. owners.
  10. Type ’help;’ or ’\h’ for help. Type ’\c’ to clear the current input statement.
  11. mysql>

查看有哪些数据库

  1. mysql> show databases;
  2. +———————-+
  3. | Database             |
  4. +———————-+
  5. | information_schema   |
  6. | mysql                |
  7. | performance_schema   |
  8. | test                 |
  9. +———————-+
  10. 4 rows in set (0.00 sec)

查看有哪些mysql用户

  1. mysql> use mysql;
  2. mysql> select user,host,password from user;
  3. +——+————+——————————————-+
  4. | user | host       | password                                  |
  5. +——+————+——————————————-+
  6. | root | localhost  | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
  7. | root | Carl-U     |                                           |
  8. | root | 127.0.0.1  |                                           |
  9. | root | ::1        |                                           |
  10. |      | localhost  |                                           |
  11. |      | Carl-U     |                                           |
  12. +——+————+——————————————-+
  13. 6 rows in set (0.00 sec)

删除密码为空的用户

  1. mysql> delete from user where password=”;
  2. Query OK, 5 rows affected (0.00 sec)

14.创建一个可以远程链接的用户

  1. mysql> grant all privileges on *.* to root@’%' identified by ’root’ with grant option;
  2. mysql> flush privileges;

15.创建一个链接

  1. carl@Carl-U:~$ sudo ln -s /usr/local/mysql/bin/mysql /usr/bin/

这时候使用mysql不会提示找不到了

  1. carl@Carl-U:~$ mysql -u root -p
  2. Enter password:
  3. Welcome to the MySQL monitor.  Commands end with ; or \g.
  4. Your MySQL connection id is 10
  5. Server version: 5.5.33-log Source distribution
  6. Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
  7. Oracle is a registered trademark of Oracle Corporation and/or its
  8. affiliates. Other names may be trademarks of their respective
  9. owners.
  10. Type ’help;’ or ’\h’ for help. Type ’\c’ to clear the current input statement.
  11. mysql>

16.安装过程中有问题请了留言。

Ubuntu 13.04中源码方式安装MySQL 5.5.33相关推荐

  1. linux上源码安装mysql,Linux中源码包安装MySQL的shell脚本

    #!/bin/bash #安装MYSQL yum -y install ncurses-devel yum -y install autoconf tar zxf /cmake--C / cd /cm ...

  2. ubuntu 16.04 Nginx源码部署安装

    nginx安装 1.安装zlib依赖库:sudo apt-get install zlib1g-dev 2.进入解压相关文件: tar –xzvf openssl-1.0.1.tar.gz tar – ...

  3. php源码无法安装mysql_linux中源码编译安装mysql常见错误

    (一) #./configure --prefix=/usr/local/mysql-5.1.54 (mysql指定路径安装报错:) 如下: checking for termcap function ...

  4. linux中源码编译安装mysql常见错误

    一) #./configure --prefix=/usr/local/mysql-5.1.54 (mysql指定路径安装报错:) 如下: checking for termcap functions ...

  5. 如何以源码安装mysql_CentOS以源码方式安装MySQL

    系统环境 CentOS 6.5 64位 MySQL 5.6.23 安装基础组件 yum -y install cmake ncurses-devel 创建用户和组 groupadd mysql use ...

  6. ubuntu安装python_ubuntu18.04下源码编译安装最新版本Python3

    原文链接:ubuntu18.04下源码编译安装最新版本Python3 截止到2019年4月9日,Python3最新的版本是3.7.3. 在ubuntu18.04中已经安装的Python3版本是3.6. ...

  7. VMware Workstation 8下Ubuntu 13.04中安装VMware Tools出错

    vm 8.0上安装ubuntu 13.04系统以后,需要安装一个vm tool 方便屏幕适应和文件拷贝,但是发现由于ubuntu 13.04 使用的内核太新了,而vm8.0 不能够提供这样的文件,导致 ...

  8. python版本升级后编译_ubuntu18.04下源码编译安装最新版本Python3

    截止到2019年4月9日,Python3最新的版本是3.7.3. 在ubuntu18.04中已经安装的Python3版本是3.6.7,下面我们就演示一下如何在ubuntu18.04下源码编译安装Pyt ...

  9. 源码方式安装的nginx注册到systemctl管理

    用源码方式安装的nginx每次都要进入安装目录才能进行启动.重启.停止操作,使用yum install nginx方式安装的话会自动注册到systemctl管理中,源码方式安装的nginx注册到sys ...

最新文章

  1. Web服务器性能/压力测试工具http_load、webbench、ab、Siege使用教程
  2. arcgis 散瓦片发布服务_利用已有的缓存地图文件发布ArcGIS Server瓦片服务
  3. C#教程之自己动手写映射第四节[封装删除]
  4. UCOS 操作系统 安装配置环境
  5. 【解惑】这么多技术我该怎么学
  6. Java向后不兼容历史的观察
  7. oracle 创交表,创建交叉报表(oracle)_oracle
  8. 【HDU - 1281 】棋盘游戏 (经典的二分图匹配,匈牙利算法,枚举删除顶点,必须边,关建边)
  9. 详解淘宝直播背后的技术!
  10. 解决Access to Message Queuing system is denied.权限问题
  11. 电力系统谐波分析代码
  12. c#+上传文件至服务器,C# 实现文件上传到服务器
  13. 迄今见过的最好的职业规划文章
  14. [CF1421E]Swedish Heroes
  15. 项目经理面试题及答案
  16. 人人都是产品经理 产品经理培训 互联网产品经理
  17. myEclipse 注册码 在线生成
  18. docker+阿里云镜像服务
  19. win7修改计算机主机名称,Windows7旗舰版计算机名称无法修改解决方法
  20. 专业工具软件课程意见汇总及答复

热门文章

  1. 论文阅读:BEVSegFormer: Bird’s Eye View Semantic Segmentation FromArbitrary Camera Rigs
  2. Amazon Simple Storage Service (Amazon S3) 简介
  3. SaaSBase:什么是Oracle Fusion ERP?
  4. [Git] Git整理(一) Git的安装、配置和基本操作
  5. 必备技能13:如何白嫖Scribd上的pdf文件
  6. Lyx使用IEEE模板编写latex论文
  7. 客流管控系统可以协助博物馆进行人数管理
  8. 趣头条自媒体怎么赚钱,趣头条真的能赚钱吗
  9. PS使用技巧方法与技巧记录
  10. HashMap、HashTable的key和value是否可为null