在Linux下安装mysql的二进制源代码包
在Linux下安装mysql的二进制源代码包,看看我的安装步骤吧!
1. 下载
2. 把下载的文件放在你的/home/soft目录
在终端输入ls,如下:
[root@MysqlDBServer soft]# ls
mysql-max-5.0.24-linux-i686.tar.gz
3. 然后用tar -zxvf mysql-max-5.0.24-linux-i686.tar.gz命令解压到当前目录
[root@localhost mysql]# tar –zxvf mysql-max-5.0.24-linux-i686.tar.gz
[root@MysqlDBServer soft]# ls
mysql-max-5.0.24-linux-i686 mysql-max-5.0.24-linux-i686.tar.gz
4. 因为用的是源代码,所以要把文件copy到安装目录/usr/local/下,才能运行!
[root@localhost mysql]# cp –rf mysql-max-5.0.24-linux-i686 /usr/local/
[root@localhost mysql]# cd /usr/local
[root@db2 local]# mv mysql-max-5.0.24-linux-i686 mysql(目录改名成mysql)
5. 查看系统有没有安装过mysql,查找并删除原来的rpm形式的mysql
[root@localhost mysql]# rpm –qa | grep mysql
有的话一个一个删除掉,用rpm -e命令,然后查找一下残留的文件:
[root@localhost mysql]# cd /
[root@localhost /]# find / -name mysql
如果查找到rm -rf filename删除.
[root@localhost /]# find / -name my.cnf
如果查找到删除,一般my.cnf是在/etc/my.cnf这里.
6. 建立mysql用户
[root@localhost mysql]#useradd mysql
[root@localhost mysql]#passwd mysql(密码为mysql)
7. 初始化mysql表格,安装 mysql 默认数据库,如下:
[root@localhost mysql]# cd /usr/local/mysql
Installing all prepared tables
Fill help tables
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 MysqlDBServer password 'new-password'
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &
You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
cd sql-bench ; perl run-all-tests
Please report any problems with the ./bin/mysqlbug .!
The latest information about MySQL is available . the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
[root@MysqlDBServer mysql]#
8. 修改目录权限,如下:
[root@localhost mysql]# cd /usr/local
[root@localhost local]# chgrp -R mysql mysql
[root@localhost local]# chown -R mysql mysql/data
[root@localhost local]# ln -sv /usr/local/mysql/bin/* /usr/local/bin/
9. 启动mysql_safe,如下:
[root@localhost local]# bin/mysqld_safe --user=mysql --socket=/tmp/mysql.sock --port=3306 &
[1] 26860
[root@localhost local]# nohup: ignoring input and redirecting stderr to stdout
Starting mysqld daemon with databases from /usr/local/mysql/data
查看一下 3308 端口是否已经在监听:
netstat -anp|grep LISTEN
10. 添加到系统自启动,如下:
[root@localhost local]# cp mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@localhost local]# chkconfig --add mysqld
查看启动进程列表
[root@MysqlDBServer soft]# chkconfig --list|grep mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
11. 启动mysql服务进程,如下:
[root@localhost local]# /etc/init.d/mysqld start
Starting MySQL [ OK ]
本文转自 pgmia 51CTO博客,原文链接:http://blog.51cto.com/heyiyi/126016