Ubuntu 13.04中源码方式安装MySQL 5.5.33
2013-11-16 00:23
477 查看
转载: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
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.安装过程中有问题请了留言。
相关文章推荐
- mysql self join的实现--left join 和inner join
- common lisp 利用cffi 操作mysql
- Mysql命令行下备份恢复数据库数据操作
- [MySQL] 数据类型与性能
- mySql主从同步设置
- Mysql的float类型造成的困扰总结
- Mysql的float类型造成的困扰总结
- Ubuntu安装和卸载MYSQL
- Mysql show indexes 查看索引状态
- magento产品页面301/302重定向
- 关于MySQL的Admin Ping Command
- Mysql的Root密码忘记,查看或修改的解决方法(图文介绍)
- 安装mysql,在./configure时出现错误:error: No curses/termcap library found的解决办法
- Mysql源码包安装
- mysql搜索引擎
- is not allowed to connect to this MySQL server
- 实现mysql 的分割字符功能
- MySQL多源复制解决方案
- 表主键自增长Mybatis插入数据报错
- mysql字符集设置