mysql5.5.32源代码安装

警告
本文最后更新于 2020-05-30 17:09,文中内容可能已过时。

mysql5.5.32源码包下载地址:

https://cdn.mysql.com/archives/mysql-5.5/mysql-5.5.32.tar.gz

1.安装依赖包

yum install -y cmake ncurses-devel

 

2.创建用户、组

groupadd mysql

useradd mysql -s /sbin/nologin -M -g mysql

 

3.解压mysql

tar xf mysql-5.5.32.tar.gz

cd mysql-5.5.32

 

4.编译

cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \

-DMYSQL_DATADIR=/application/mysql-5.5.32/data \

-DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DEXTRA_CHARSET=gbk,gb2312,utf8,ascii \

-DENABLED_LOCAL_INFILE=on \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_FEDERATED_STORAGE_ENGINE=1 \

-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

-DWITHOUT_EXAMPL_ESTORAGE_ENGINE=1 \

-DWITHOUT_PARTITION_ESTORAGE_ENGINE=1 \

-DWITH_FAST_MUTEXES=1 \

-DWITH_ZLIB=bundled \

-DENABLED_LOCAL_INFILE=1 \

-DWITH_READLINE=1 \

-DWITH_ENBEDDED_SERVER=1 \

-DWITH_DEBUG=0

 

5.安装

make && make install

 

6.创建软链接

ln –s /application/mysql-5.5.32/ /application/mysql

 

7.复制配置文件

cp /application/mysql/support-files/my-small.cnf /etc/my.cnf

 

8.配置环境变量

echo ’export PATH=/application/mysql/bin:$PATH’ >> /etc/profile

source /etc/profile

 

9.初始化mysql

chown -R mysql:mysql /application/mysql/data

/application/mysql/scripts/mysql_install_db –user=mysql –basedir=/application/mysql –datadir=/application/mysql/data

 

10.创建启动脚本

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

chmod +x /etc/init.d/mysqld

 

11.启动服务并设置开机自启

service mysqld start

chkconfig mysqld on

 

12.创建和更改密码

/application/mysql//bin/mysqladmin -u root password ’new-password'

或 /application/mysql//bin/mysqladmin -u root -h localhost password ’new-password'

 

13.删除mysql空用户

mysql> delete from mysql.user where user=’';

 

14.删除test库

mysql> drop database test;

 

请我喝杯水
SoulChild 微信号 微信号
SoulChild 微信打赏 微信打赏
0%