1、服务器系统: CentOS 系统, 我的系统是最小化安装有的软件包没有需要在安装
2、安装需要软件包:yum install compat-libstdc++ cpp gcc libstdc++-devel gcc-c++ -y
3、下载 MYSQL 源包地址: http://www.mysql.com/downloads/mysql/#downloads
4、解压下载文件:tar zxvf mysql-5.1.44.tar.gz
5、进入目录: cd mysql-5.1.44
6、配置文件参数, 此操作把MYSQL 安装到了 /usr/local/mysql 目录下:
./configure \
–prefix=/usr/local/mysql \
–enable-assembler \
–with-extra-charsets=complex \
–without-debug \
–with-pthread \
–enable-thread-safe-client \
–with-charset=utf8 \
–enable-thread-safe-client \
–with-mysqld-ldflags=-all-static
7、以上没有错误的话接着执行以下语句
make
make install
8、配置MYSQL参数:
cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
groupadd mysql
useradd -g mysql mysql
/usr/local/mysql/bin/mysql_install_db –user=mysql
cd /usr/local/mysql/
chown -R root .
chown -R mysql var
chgrp -R mysql .
bin/mysqld_safe –user=mysql &
ln -s /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
/usr/local/mysql/bin/mysqladmin -uroot password 数据库密码
3、下载 MYSQL 源包地址: http://www.mysql.com/downloads/mysql/#downloads
4、解压下载文件:tar zxvf mysql-5.1.44.tar.gz
5、进入目录: cd mysql-5.1.44
6、配置文件参数, 此操作把MYSQL 安装到了 /usr/local/mysql 目录下:
./configure \
–prefix=/usr/local/mysql \
–enable-assembler \
–with-extra-charsets=complex \
–without-debug \
–with-pthread \
–enable-thread-safe-client \
–with-charset=utf8 \
–enable-thread-safe-client \
–with-mysqld-ldflags=-all-static
7、以上没有错误的话接着执行以下语句
make
make install
8、配置MYSQL参数:
cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
groupadd mysql
useradd -g mysql mysql
/usr/local/mysql/bin/mysql_install_db –user=mysql
cd /usr/local/mysql/
chown -R root .
chown -R mysql var
chgrp -R mysql .
bin/mysqld_safe –user=mysql &
ln -s /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
/usr/local/mysql/bin/mysqladmin -uroot password 数据库密码
9、进入Mysql
/usr/local/mysql/bin/mysql -uroot -p 回车后输入密码 如果数据库没有设置密码 就直接回车
10、设置Linux机器启动,Mysql自动启动
vim /etc/rc.local
添加如下内容:
/etc/init.d/mysqld start
这样机器重新启动, Mysql也会自动启动了
11、如果你忘记了数据库密码该如何操作呢?
vim /etc/my.cnf
添加如下内容:
skip-grant-tables
重启数据库: /etc/init.d/mysqld restart
进入Mysql: /usr/local/mysql/bin/mysql -uroot
进入后操作命令
user mysql; 回车
UPDATE user SET Password=PASSWORD(‘你的数据库新密码’) where USER=’root’; 回车
vim /etc/my.cnf 去除刚才添加的那行 然后在重启 就可以用你的新密码了。
转载请注明:苏demo的别样人生 » Linux 下 MYSQL 编译源码安装操作