MySQL源码编译安装

mysql 官网下载 tar包
1G 内存的话建议安装 5.6版本,5.7版本消耗内存根本吃不消
MySQl 官网下载选项
https://dev.mysql.com/downloads/mysql/
MySQL Community Server 5.6.37
Select Version: 5.6.37
Select Operating System: Source Code
Select OS Version: Generic Linux

yum install bison cmake

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/  -DMYSQL_DATADIR=/usr/local/mysql/data  -DWITH_INNOBASE_STORAGE_ENGINE=1  -DMYSQL_TCP_PORT=3306  -DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock  -DMYSQL_USER=mysql  -DWITH_DEBUG=0  

make
make install

scripts/mysql_install_db --user=mysql  --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data 

===
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h iZwz9bx5oesz31ozyxls5eZ password 'new-password'

Alternatively you can run:
/usr/local/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr/local/mysql ; 
/usr/local/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/
cp support-files/my-medium.cnf /etc/my.cnf

设置 MySQL 启动项

cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on

chown -R mysql:mysql /usr/local/mysql
ln -s /usr/local/mysql/bin/mysql /usr/bin/
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容