您的位置:首页 > 数据库 > MySQL

源码安装mysql

2015-08-09 13:59 671 查看
1准备条件

redhat 环境, cmake-2.8.8.tar.gz,mysql-5.5.32.tar.gz

2安装cmake的依赖包

wget ftp://invisible-island.net/ncurses/ncurses.tar.gz

yum install g++

解压ncurses.tar.gz

tar -zxvf ncurses.tar.gz

cd ncurses-5.9

./configure

make && make install

3.安装cmake

tar -zxvf cmake-2.8.8.tar.gz
cd cmake-2.8.8

./configure

make && make install

4.安装mysql

mkdir /usr/local/mysql//创建目录

cp mysql-5.5.32.tar.gz /usr/local/mysql 复制文件到mysql目录下

cd /usr/local/mysql 切换到mysql目录下

tar -zxvf mysql-5.5.32.tar.gz

[root@localhost mysql]# cd mysql-5.5.32

编译mysql

cmake \


-DCMAKE_INSTALL_PREFIX=

/usr/local/mysql

\


-DMYSQL_DATADIR=

/data/mysql/data

\


-DSYSCONFDIR=

/etc

\


-DWITH_MYISAM_STORAGE_ENGINE=1 \


-DWITH_INNOBASE_STORAGE_ENGINE=1 \


-DWITH_MEMORY_STORAGE_ENGINE=1 \


-DWITH_READLINE=1 \


-DMYSQL_UNIX_ADDR=

/tmp/mysql/mysql

.sock \


-DMYSQL_TCP_PORT=3306 \


-DENABLED_LOCAL_INFILE=1 \


-DWITH_PARTITION_STORAGE_ENGINE=1 \


-DEXTRA_CHARSETS=all \


-DDEFAULT_CHARSET=utf8 \


-DDEFAULT_COLLATION=utf8_general_ci


安装mysql

[root@localhost mysql-5.5.32]# make && make install

添加系统mysql组和mysql用户:

groupadd mysql

useradd -r -g mysql mysql

安装数据库:

进入安装mysql软件目录:执行命令 cd /usr/local/mysql

修改当前目录拥有者为mysql用户:执行命令 chown -R mysql:mysql ./

安装数据库:执行命令 ./scripts/mysql_install_db --user=mysql

修改当前目录拥有者为root用户:执行命令 chown -R root:root ./

修改当前data目录拥有者为mysql用户:执行命令 chown -R mysql:mysql data

到此数据库安装完毕

启动mysql服务和添加开机启动mysql服务:

添加开机启动:执行命令cp support-files/mysql.server /etc/init.d/mysql,把启动脚本放到开机初始化目录

启动mysql服务:执行命令service mysql start

创建软连接

ln -s /usr/local/mysql/bin/mysql /usr/bin

执行命令:ps -ef|grep mysql 看到mysql服务说明启动成功

如果出现 service mysql start Starting MySQL.The server quit without updating PID file (/data/mysql/data/localhost.localdomain.pid). [FAILED]

4 本人解决过程

[root@localhost ~]# cd /usr/local/mysql

[root@localhost mysql]# chown -R mysql.mysql .
[root@localhost mysql]# su - mysql
[mysql@localhost ~]$ cd /usr/local/mysql
[mysql@localhost mysql]$scripts/mysql_install_db
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:

./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:
./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 . ; ./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl

Please report any problems with the ./bin/mysqlbug script!

[mysql@localhost mysql]$ /usr/local/mysql/bin/mysqld_safe --user=mysql &
[1] 11767
[mysql@localhost mysql]$ 120502 07:01:17 mysqld_safe Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
120502 07:01:17 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
[mysql@localhost mysql]$ /etc/rc.d/init.d/mysql status
MySQL running (11830)

[ OK ]
[mysql@localhost mysql]$ /etc/rc.d/init.d/mysql start
Starting MySQL [ OK ]

从新登陆

[root@localhost mysql]# mysql -uroot -p --默认没有设置密码
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.32 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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: