欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

MySQL源码安装完成后修改安装路径启动问题

程序员文章站 2024-02-19 13:19:58
...

在Linux上源码编译安装完mysql后,又将安装的路径进行了修改,但是发现在设置后环境变量后启动报错,如下:[root@www.linuxidc.c

在Linux上源码编译安装完mysql后,又将安装的路径进行了修改,但是发现在设置后环境变量后启动报错,如下:

[root@ var]# mysqld_safe --user=mysql &

[1] 31248

[root@ var]# 110422 11:04:00 mysqld_safe Logging to '/opt/mysql5156/var/HServer_03.err'.

touch: cannot touch `/opt/mysql5156/var/HServer_03.err': No such file or directory

chown: cannot access `/opt/mysql5156/var/HServer_03.err': No such file or directory

110422 11:04:00 mysqld_safe The file /opt/mysql5156/libexec/mysqld

does not exist or is not executable. Please cd to the mysql installation

directory and restart this script from there as follows:

./bin/mysqld_safe&

See for more information

/usr/local/mysql/bin/mysqld_safe: line 100: /opt/mysql5156/var/HServer_03.err: No such file or directory

[1]+ Exit 1 mysqld_safe --user=mysql

按照提示原有的路径目录不存在,需要到mysql的相对路径下启动~

我的原安装路径是在/opt/mysql5156下,具体的安装过程:

Shell> tar –zxvvf mysql-5.1.56.tar.gz

Shell> cd mysql-5.1.56

Shell> ./configure --prefix=/opt/mysql5156 \

--with-charset=utf8 --with-collation=utf8_general_ci \

--with-extra-charsets=latin1,gb2312 \

--with-plugins=innobase,innodb_plugin,myisam,heap,csv,federated,blackhole \

--enable-local-infile --enable-thread-safe-client

Shell> make

Shell >make install

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

Shell>cd /opt/mysql5156

Shell>chown –R mysql .

Shell>chgrp –R mysql .

Shell>bin/mysql_install_db –user=mysql

Shell>chown –R root .

Shell> chown –R mysql var

Shell>vi /root/.bash_profile

PATH=$PATH:$HOME/bin:/opt/mysql5156/bin

现在将/opt/mysql5156/目录移动到/usr/local/下:

Shell>mv /opt/mysql5156 /usr/local/mysql

Shell>vi /root/.bash_profile

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

Shell>source /root/.bash_profile

在启动时出现上述错误的主要原因是mysql在编译安装时,将路径/opt/mysql5156写入了mysql/bin/mysqld_safe脚本中,打开该脚本可以明确看到各个启动逻辑的判断都有/opt/mysql5156的影子,,那么将所有的/opt/mysql5156 全局替换为/usr/local/mysql,保存后重新启动,ok了。

另外由于这次的编译安装时采用动态编译的,还需要修改mysql的动态函式库,

Shell>vi /etc/ld.so.conf

/usr/local/mysql/lib/mysql/

Shell>ldconfig

这样在新的路径下,编译安装的mysql就可以无碍使用了。

MySQL源码安装完成后修改安装路径启动问题