数据库
首页 > 数据库> > Mysql5.1源码编译安装

Mysql5.1源码编译安装

作者:互联网

1.源码包安装,需要编译方式安装(选择20以上版本)

mysql-5.1.72.tar.gz

5.1的版本需要用常规编译方式,5.5版本以上需要用cmake方式编译

2.mysql-5.1.70-linux-i686-glibc23.tar.gz解压开就可以使用(32位)

[root@localhost ~]# mkdir -p /application/mysql5.1.72

[root@hcf mysql-5.1.72]# groupadd mysql

[root@Apachetools]#      useradd mysql –s /sbin/nologin –g mysql –M

Usage: useradd [options] LOGIN

       useradd -D

       useradd -D [options]

出现参数提示(s和m前面的-不对)

[root@hcf mysql-5.1.72]# useradd mysql -s /sbin/nologin -g mysql -M

[root@hcf mysql-5.1.72]# tar zxf mysql-5.1.72.tar.gz

[root@hcf mysql-5.1.72]# cd mysql-5.1.72

[root@hcf mysql-5.1.72]在目录中执行以下命令

./configure \

--prefix=/application/mysql5.1.72 \

--with-unix-socket-path=/application/mysql5.1.72/tmp/mysql.sock \

--localstatedir=/application/mysql5.1.72/data \

--enable-assembler \

--enable-thread-safe-client \

--with-mysqld-user=mysql \

--with-big-tables \

--without-debug \

--with-pthread \

--enable-assembler \

--with-extra-charsets=complex \

--with-readline \

--with-ssl \

--with-embedded-server \

--enable-local-infile \

--with-plugins=partition,innobase \

--with-mysqld-ldflags=-all-static \

--with-client-ldflags=-all-static

错误:

checking for termcap functions library... configure: error: No curses/termcap library found

解决:

yum –y install ncurses-devel(没解决)

yum install libtermcap-devel –y(解决) http://blog.csdn.net/anljf/article/details/6982057

执行成功:

/bin/rm: cannot remove `libtoolT': No such file or directory

config.status: executing default commands

 

Thank you for choosing MySQL!

 

Remember to check the platform specific part of the reference manual

for hints about installing MySQL on your platform.

Also have a look at the files in the Docs directory.

[root@hcf mysql-5.1.72]# make && make install(执行时间较长,可提前将内存调大些)

[root@hcf mysql-5.1.72]# echo $?

0

[root@hcf tools]# ll mysql-5.1.72/support-files/*.cnf

-rw-r--r--. 1 root root  4746 Sep 22 12:59 mysql-5.1.72/support-files/my-huge.cnf

-rw-r--r--. 1 root root 19779 Sep 22 12:59 mysql-5.1.72/support-files/my-innodb-heavy-4G.cnf

-rw-r--r--. 1 root root  4720 Sep 22 12:59 mysql-5.1.72/support-files/my-large.cnf

-rw-r--r--. 1 root root  4731 Sep 22 12:59 mysql-5.1.72/support-files/my-medium.cnf

-rw-r--r--. 1 root root  2499 Sep 22 12:59 mysql-5.1.72/support-files/my-small.cnf

 

support-files下有mysql my.cnf的各种配置案例.英文注释非常详细.

安装为测试安装,因此,选择参数配置小的my-small.cnf配置模板

创建mysql数据库文件

[root@hcf application]# ln -s /application/mysql5.1.72/ /application/mysql

[root@hcf tools]# mkdir -p /application/mysql/data  建立mysql数据文件目录

[root@hcf tools]# chown -R mysql /application/mysql 授权mysql用户访问mysql的安装目录

Chown –R 1777 /tmp

安装数据库初始化文件(不能有错误,warning可以忽略)/mysql/data目录下安装文件

[root@hcf application]# /application/mysql/bin/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data --user=mysql

初始化成功:

WARNING: The host 'hcf' 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...

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:

 

/application/mysql/bin/mysqladmin -u root password 'new-password'

/application/mysql/bin/mysqladmin -u root -h hcf password 'new-password'

 

Alternatively you can run:

/application/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 /application/mysql ; /application/mysql/bin/mysqld_safe &

 

You can test the MySQL daemon with mysql-test-run.pl

cd /application/mysql/mysql-test ; perl mysql-test-run.pl

 

Please report any problems with the /application/mysql/scripts/mysqlbug script!

  1. 处理/tmp目录

ls –ld /tmp

chmod –R 777 /tmp/

  1. 修改主机名的解析和uname –n一样

grep ‘uname –n’ /etc/hosts

强调:此步骤必须成功,否则,后面会出现登录不了数据库等各种问题发生.

[root@hcf application]# uname –n  和@后面的名字一样

Hcf

如果不一样,vi /etc/hosts   /etc/sysconfig/network

启动数据库(安装目录下系统提供的脚本)

[root@hcf tools]# cp mysql-5.1.72/support-files/mysql.server /application/mysql/bin/

[root@hcf tools]# chmod 755 /application/mysql/bin/mysql.server

[root@hcf tools]# /application/mysql/bin/mysql.server start

Starting MySQL..Manager of pid-file quit without updating f[FAILED]

解决:拷贝配置文件,并改名为my.cnf

[root@hcf tools]# cp mysql-5.1.72/support-files/my-small.cnf /etc/my.cnf

[root@hcf tools]# /application/mysql/bin/mysql.server start            

Starting MySQL..                                           [  OK  ]

[root@hcf tools]# mysql没有加到环境变量中

-bash: mysql: command not found

[root@hcf tools]# mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.1.72 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登录不上去

报错: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

解决:Killall -9 mysqld     pkill mysqld

lsof –i :3306

rm -fr /application/mysql/data/*

/application/mysql/bin/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data --user=mysql

[root@hcf tools]# cp /application/mysql/bin/mysql.server /etc/init.d/mysqld

[root@hcf tools]# chkconfig mysqld on

[root@hcf tools]# chkconfig --list mysqld

mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off

[root@hcf tools]# mysqladmin -u root password 'wj123' root需密码,普通用户可以直接登录

mysql> select user,host from mysql.user;

mysql> select user,host from mysql.user \G;可以竖着显示

mysql> drop user ''@'localhost'; 有大写或特殊字符时,drop不管用,使用delete去表中删除

mysql> delete from mysql.user where user="" and host="localhost";

mysql> flush privileges;刷新权限

标签:5.1,编译,Mysql5.1,application,源码,hcf,72,mysql,root
来源: https://blog.csdn.net/qq_34412985/article/details/98446728