现在的位置: 首页 > 综合 > 正文

mysql 源码安装

2012年03月18日 综合 ⁄ 共 2729字 ⁄ 字号 评论 1 条

Mysql下载地址:http://www.mysql.com/downloads/mysql/
1.下载mysql源码并解压
[root@server3 ~]# tar zxf mysql-5.1.58.tar.gz
[root@server3 ~]# cd mysql-5.1.58

2.配置选项
[root@server3 mysql-5.1.58]# ./configure --prefix=/usr/local/mysql5.1.58 \
--localstatedir=/usr/local/mysql5.1.58/data \
--without-debug \
--without-ndb-debug \
--with-collation=utf8_general_ci \
--enable-thread-safe-client \
--enable-assembler \
--enable-profiling \
--with-big-tables \
--with-mysqld-ldflags=-all-static \
--with-client-ldflags=-all-static \
--with-charset=utf8 \
--with-extra-charsets=all \
--with-plugins=innobase,partition \
--with-mysqld-user=mysql \
--without-embedded-server \
--with-unix-socket-path=/tmp/mysql.sock

3.编译安装
[root@server3 mysql-5.1.58]#make && make install

4.增加mysql 用户
[root@server3 mysql-5.1.58]#useradd mysql

5.建立数据目录
[root@server3 mysql-5.1.58]#mkdir /usr/local/mysql5.1.58/data

6.复制配置文件到mysql安装目录
[root@server3 mysql-5.1.58]# cp support-files/my-medium.cnf /usr/local/mysql5.1.58/my.cnf

7.改变mysql安装目录的属主和属组为mysql和root
[root@server3 mysql-5.1.58]#chown -R root:mysql /usr/local/mysql5.1.58

8.把mysql数据目录的属主和属组修改为mysql和mysql,使mysql用户可以写入
[root@server3 mysql-5.1.58]#chown -R mysql:mysql/usr/local/mysql5.1.58/data

9.以mysql用户身份初始化数据库
[root@server3 mysql-5.1.58]#/usr/local/mysql5.1.58/bin/mysql_install_db --basedir=/usr/local/mysql5.1.58 --user=mysql

10.启动Mysql服务
[root@server3 ~]# /usr/local/mysql5.1.58/bin/mysqld_safe --defaults-file=/usr/local/mysql5.1.58/my.cnf --user=mysql &
要开机启动服务把这条命令放到/etc/rc.local中

11.配置PATH路径
编辑vim /etc/profile,把mysql的bin目录加入到PATH路径里面
export PATH=/usr/local/mysql5.1.58/bin:$PATH
[root@server3 ~]#source /etc/profile

12.登录到mysql,由于没有mysql的root用户没有设置密码,所以直接输入mysql就可以登录
[root@server3 ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.58-log Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit

13.修改mysql的root用户密码
[root@server3 ~]# mysqladmin -u root password '123456'

14.再次登录到mysql
[root@server3 ~]# mysql -uroot -p
Enter password: //这里输入root用户的密码
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.1.58-log Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.00 sec)

mysql>

15.关闭mysql服务
[root@server3 ~]#mysqladmin -uroot -p shutdown
Enter password: //输入mysql的root用户密码

目前有 1 条留言    访客:1 条, 博主:0 条

  1. Misa 2012年03月20日 下午 11:24  @回复  Δ1楼 回复

    Wonderful blog! I found it while searching on Yahoo News. Do you have any tips on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Many thanks

给我留言

留言无头像?