liunx编译 安装mysql_linux编译安装mysql

紧接着上文,这次是重装mysql,正好之前有人要lnmp的安装方法,算上这篇文章就全了。

安装前准备

如果mysql用户不存在,那么添加mysql用户

groupadd mysql

useradd -g mysql mysql

1

2groupaddmysql

useradd-gmysqlmysql

mysql编译安装

wget http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.70.tar.gz

tar -zxvf mysql-5.1.70.tar.gz

cd mysql-5.1.70

yum install ncurses ncurses-devel

./configure '--prefix=/usr/local/mysql' '--without-debug' '--with-charset=utf8' '--with-extra-charsets=all' '--enable-assembler' '--with-pthread' '--enable-thread-safe-client' '--with-mysqld-ldflags=-all-static' '--with-client-ldflags=-all-static' '--with-big-tables' '--with-readline' '--with-ssl' '--with-embedded-server' '--enable-local-infile' '--with-plugins=innobase'

make

make install

1

2

3

4

5

6

7

8wgethttp://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.70.tar.gz

tar-zxvfmysql-5.1.70.tar.gz

cdmysql-5.1.70

yuminstallncursesncurses-devel

./configure'--prefix=/usr/local/mysql''--without-debug''--with-charset=utf8''--with-extra-charsets=all''--enable-assembler''--with-pthread''--enable-thread-safe-client''--with-mysqld-ldflags=-all-static''--with-client-ldflags=-all-static''--with-big-tables''--with-readline''--with-ssl''--with-embedded-server''--enable-local-infile''--with-plugins=innobase'

make

makeinstall

到此mysql就安装到了/usr/local/mysql路径下,下面开始mysql的配置工作

------------------------------------

安装mysql选项文件

cp support-files/my-medium.cnf /etc/my.cnf

1cpsupport-files/my-medium.cnf/etc/my.cnf

mysql设置开机自启动

cp -r support-files/mysql.server /etc/init.d/mysqld

/sbin/chkconfig --del mysqld

/sbin/chkconfig --add mysqld

1

2

3cp-rsupport-files/mysql.server/etc/init.d/mysqld

/sbin/chkconfig--delmysqld

/sbin/chkconfig--addmysqld

配置权限表

chown -R mysql:mysql /usr/local/mysql

/usr/local/mysql/bin/mysql_install_db --user=mysql

1

2chown-Rmysql:mysql/usr/local/mysql

/usr/local/mysql/bin/mysql_install_db--user=mysql

启动mysql

/etc/init.d/mysqld start

1/etc/init.d/mysqldstart

这一步可能会报错

/etc/init.d/mysqld: line 260: my_print_defaults: command not found

/etc/init.d/mysqld: line 263: my_print_defaults: command not found

/etc/init.d/mysqld: line 270: @HOSTNAME@: command not found

/etc/init.d/mysqld: line 279: @HOSTNAME@: command not found

/etc/init.d/mysqld: line 292: cd: @prefix@: No such file or directory

Starting MySQLCouldn't find MySQL manager (@bindir@/mysqlmanager) or server (@bindir@/mysqld_safe) [FAILED]

因为路径没有设置,请重启确认上面配置工作是否都完成,一般是configure后没有make和make install。

mysql初始化配置:

export PATH=/usr/local/mysql/bin:$PATH

/usr/local/mysql/bin/mysql_secure_installation

1

2exportPATH=/usr/local/mysql/bin:$PATH

/usr/local/mysql/bin/mysql_secure_installation

mysql如何导入旧的数据:

直接拷贝数据库文件夹到数据目录下然后执行

/usr/local/mysql/bin/mysqladmin -u root -p flush-tables

1/usr/local/mysql/bin/mysqladmin-uroot-pflush-tables

==================================================================

mysql安装过程中问题

1.

make[2]: Entering directory /down/webinstall/mysql-5.1.57/mysql-test

make[3]: Entering directory/down/webinstall/mysql-5.1.57/mysql-test

make[3]: Nothing to be done for install-exec-am.

make INSTALL_TO_DIR="/usr/local/mysql/mysql-test" install_test_files

make[4]: Entering directory/down/webinstall/mysql-5.1.57/mysql-test

时间较长

MYSQL安装到这里卡了很久,可能以为出错了,实际上MYSQL已经安装成功了,它这步过段时间就会好了,是mysql在自我编译测试造成的。

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

yum install ncurses ncurses-devel

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

启动数据库之前,需要先配置权限表,其中/usr/local/mysql为mysql的安装目录

chown -R mysql:mysql /usr/local/mysql

/usr/local/mysql/bin/mysql_install_db --user=mysql

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值