Ubuntu 13.04中源码方式安装MySQL 5.5.33
来源:互联网 发布:金融 知乎 编辑:程序博客网 时间:2024/06/07 01:07
转载: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
- carl@Carl-U:~$ sudo apt-get remove mysql*
3.添加用户组和用户
- carl@Carl-U:~$ sudo groupadd mysql
- carl@Carl-U:~$ sudo useradd -r -g mysql mysql
4.创建MySQL的安装目录
- carl@Carl-U:~$ sudo mkdir /usr/local/mysql
5.修改MySQL安装目录所有者
- carl@Carl-U:~$ sudo chown mysql:mysql /usr/local/mysql/
6.解压源码包
- carl@Carl-U:~$ sudo tar -zxvf mysql-5.5.33.tar.gz
7.进入 mysql-5.5.33目录内,因为在新版本的MySQL源码包中没有了configure,改用cmake方式编译。如果没有安装,先安装cmake
- carl@Carl-U:~$ sudo apt-get install cmake
- carl@Carl-U:~$ sudo apt-get install libncurses5-dev
注:ubuntu下安装libncurses5-dev;redhat下安装ncurses-devel
还需要其他程序
- carl@Carl-U:~$ sudo apt-get install g++
- carl@Carl-U:~$ sudo apt-get install bison
- carl@Carl-U:~$ sudo apt-get install libaio1
8.编译
- carl@Carl-U:~$ sudo cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
- -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock
- -DDEFAULT_CHARSET=utf8
- -DDEFAULT_COLLATION=utf8_general_ci
- -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk
- -DWITH_MYISAM_STORAGE_ENGINE=1
- -DWITH_INNOBASE_STORAGE_ENGINE=1
- -DWITH_MEMORY_STORAGE_ENGINE=1
- -DWITH_READLINE=1
- -DENABLED_LOCAL_INFILE=1
- -DMYSQL_DATADIR=/usr/local/mysql/data
- -DMYSQL_USER=mysql
- -DMYSQL_TCP_PORT=3306
编译结束后,出现下面的警告,不妨碍执行make
- ……
- – Generating done
- CMake Warning:
- Manually-specified variables were not used by the project:
- MYSQL_USER
- WITH_MEMORY_STORAGE_ENGINE
- – Build files have been written to: /home/carl/mysql-5.5.33
9.执行make和make install
- carl@Carl-U:~/mysql-5.5.33$ sudo make
- – Running cmake version 2.8.10.1
- – Looking for SHM_HUGETLB
- – Looking for SHM_HUGETLB - found
- – MySQL 5.5.33
- – Looking for sys/types.h
- – Looking for sys/types.h - found
- – Looking for stdint.h
- ……
- carl@Carl-U:~/mysql-5.5.33$ sudo make install
- [ 0%] Built target INFO_BIN
- [ 0%] Built target INFO_SRC
- [ 0%] Built target abi_check
- [ 2%] Built target zlib
- ……
10.从源码目录拷贝一些配置文件
- carl@Carl-U:~$ cd /home/carl/mysql-5.5.33/support-files/
- carl@Carl-U:~/mysql-5.5.33/support-files$ sudo cp my-medium.cnf /etc/my.cnf
- carl@Carl-U:~/mysql-5.5.33/support-files$ sudo cp mysql.server /etc/init.d/mysql
还要给/etc/init.d/mysql一个可执行的权限
- carl@Carl-U:~/mysql-5.5.33/support-files$ sudo chmod +x /etc/init.d/mysql
修改一下这个文件
- carl@Carl-U:~/mysql-5.5.33/support-files$ sudo vi /etc/init.d/mysql
- //修改内容
- basedir=/usr/local/mysql/
- datadir=/usr/local/mysql/data/
11.初始化数据库
进入MySQL安装后的目录
- carl@Carl-U:~/mysql-5.5.33$ cd /usr/local/mysql/
- carl@Carl-U:/usr/local/mysql$ sudo scripts/mysql_install_db –user=mysql –basedir=/usr/local/mysql/ –datadir=/usr/local/mysql/data
出现以下提示
- Installing MySQL system tables…
- OK
- Filling help tables…
- OK
- To start mysqld at boot time you have to copy
- support-files/mysql.server to the right place for your system
- PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
- To do so, start the server, then issue the following commands:
- /usr/local/mysql//bin/mysqladmin -u root password ’new-password’
- /usr/local/mysql//bin/mysqladmin -u root -h Carl-U password ’new-password’
- Alternatively you can run:
- /usr/local/mysql//bin/mysql_secure_installation
- which will also give you the option of removing the test
- databases and anonymous user created by default. This is
- strongly recommended for production servers.
- See the manual for more instructions.
- You can start the MySQL daemon with:
- cd /usr/local/mysql/ ; /usr/local/mysql//bin/mysqld_safe &
- You can test the MySQL daemon with mysql-test-run.pl
- cd /usr/local/mysql//mysql-test ; perl mysql-test-run.pl
- Please report any problems with the /usr/local/mysql//scripts/mysqlbug script!
12.启动MySQL服务
- carl@Carl-U:/usr/local/mysql$ sudo /etc/init.d/mysql start
- Starting MySQL
- ….. *
13.修改数据库root用户的密码
- carl@Carl-U:~$ sudo /usr/local/mysql/bin/mysqladmin -u root password ’root’
13.登录
这时候直接输入mysql是找不到的
需要使用/usr/local/mysql/bin/mysql
- carl@Carl-U:~$ sudo /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 2
- Server version: 5.5.33-log Source distribution
- Copyright (c) 2000, 2013, 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> show databases;
- +———————-+
- | Database |
- +———————-+
- | information_schema |
- | mysql |
- | performance_schema |
- | test |
- +———————-+
- 4 rows in set (0.00 sec)
查看有哪些mysql用户
- mysql> use mysql;
- mysql> select user,host,password from user;
- +——+————+——————————————-+
- | user | host | password |
- +——+————+——————————————-+
- | root | localhost | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
- | root | Carl-U | |
- | root | 127.0.0.1 | |
- | root | ::1 | |
- | | localhost | |
- | | Carl-U | |
- +——+————+——————————————-+
- 6 rows in set (0.00 sec)
删除密码为空的用户
- mysql> delete from user where password=”;
- Query OK, 5 rows affected (0.00 sec)
14.创建一个可以远程链接的用户
- mysql> grant all privileges on *.* to root@’%' identified by ’root’ with grant option;
- mysql> flush privileges;
15.创建一个链接
- carl@Carl-U:~$ sudo ln -s /usr/local/mysql/bin/mysql /usr/bin/
这时候使用mysql不会提示找不到了
- carl@Carl-U:~$ mysql -u root -p
- Enter password:
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 10
- Server version: 5.5.33-log Source distribution
- Copyright (c) 2000, 2013, 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>
16.安装过程中有问题请了留言。
- Ubuntu 13.04中源码方式安装MySQL 5.5.33
- ubuntu源码安装mysql
- ubuntu 源码安装Mysql
- ubuntu源码安装mysql
- ubuntu 10.10 源码编译安装mysql 5.5
- 在virtualBox中安装Ubuntu虚拟机、实现文件共享、外网访问、主宿机组成内网访问、Mysql源码方式在ubuntu下的安装
- Ubuntu编译安装mysql源码
- ubuntu中安装Mysql
- Ubuntu中mysql安装
- 在ubuntu中用源码编译方式安装好了mysql和php
- 源码方式ntop安装记录(debian/ubuntu)
- ubuntu linux源码方式安装unzip
- Ubuntu 16.04 源码方式安装 JDK
- ubuntu中cmake源码安装
- ubuntu 10.10 下 源码编译安装mysql 5.5.8
- [Ubuntu] ubuntu中openssh的源码安装
- 在Ubuntu中通过源码安装编译安装软件(MySQL篇)
- CentOS以源码方式安装MySQL
- linux套接字
- CocoaPod 使用
- static
- 经济时代,小资生活
- SQL Server 存储过程
- Ubuntu 13.04中源码方式安装MySQL 5.5.33
- iOS PDF之旅(二)将PDF文件Open In MyApp
- 如何看一个企业的成功?
- 企业为什么要用营销型网站
- 第二章 Unicode编码 学习笔记
- Advanced COM Interop
- 指针和引用的区别详解
- Win32多线程之原子操作
- java 字体从下往上循环播放