mysql5.6.8源码安装过程
程序员文章站
2022-03-17 13:13:11
内核:
[root@opop ~]# cat /etc/centos-release
centos release 6.8 (final)
[root@op...
内核:
[root@opop ~]# cat /etc/centos-release centos release 6.8 (final) [root@opop ~]# uname -a linux opop 2.6.32-642.el6.x86_64 #1 smp tue may 10 17:27:01 utc 2016 x86_64 x86_64 x86_64 gnu/linux
开始安装:
[root@opop ~]# for i in `rpm -qa | grep mysql`;do yum remove $i;done //先删除自带的mysql [root@opop ~]# yum -y install wget gcc gcc-c++ ncurses-devel cmake make perl bison git
创建mysql用户组:
[root@opop ~]# groupadd mysql [root@opop ~]# useradd -r -g mysql mysql
创建mysql安装目录和数据库文件存放目录:
[root@opop ~]# mkdir -p /usr/local/mysql [root@opop ~]# mkdir -p /usr/local/mysql/data
修改目录属主和属组:
[root@opop ~]# chown -r mysql:mysql /usr/local/mysql/data [root@opop ~]# chown -r mysql:mysql /usr/local/mysql
解包:
[root@opop ~]# tar -zxvf mysql-5.6.38.tar.gz [root@opop ~]# cd mysql-5.6.38
编译:
[root@opop mysql-5.6.38 ]# cmake \ -dcmake_install_prefix=/usr/local/mysql \ -dmysql_unix_addr=/usr/local/mysql/mysql.sock \ -ddefault_charset=utf8 \ -ddefault_collation=utf8_general_ci \ -dwith_innobase_storage_engine=1 \ -dwith_archive_storage_engine=1 \ -dwith_blackhole_storage_engine=1 \ -dmysql_datadir=/usr/local/mysql/data \ -dmysql_tcp_port=3306 \ -dmysql_user=mysql \ -denable_downloads=1 [root@opop mysql-5.6.38 ]# make && make install //注:编译时间较长,需要耐心等待 //查看下结果: //[root@opop mysql-5.6.38 ]# ll /usr/local/mysql/
清除临时文件:
[root@opop mysql-5.6.38 ]# make clean
初始化mysql:
[root@opop ~]# cd /usr/local/mysql/ [root@opop mysql]# scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data [root@opop mysql ]# chown -r mysql:mysql /usr/local/mysql [root@opop mysql ]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql [root@opop mysql ]# /etc/init.d/mysql start [root@opop mysql ]# ps -aux |grep mysql
配置环境变量:
[root@opop mysql]# vim /etc/profile
在后面加上
path=$path:$home/bin:/usr/local/mysql/bin:/usr/local/mysql/lib export path
重新加载profile(是立即生效)
[root@opop mysql]# source /etc/profile
重启mysql服务:
[root@opop mysql]# service mysql restart
首次登陆:
[root@opop mysql]# mysql -u root mysql
授权:
mysql> grant all privileges on *.* to root@"%" identified by "root"; //为root添加远程连接的能力,据需谨慎操作。
设置数据库密码:
mysql> update user set password = password('111111') where user='root'; //更新root密码为6个1
刷新:
mysql> flush privileges;
退出:
mysql> exit
更改完密码以后再次登录:
[root@opop mysql]# mysql -u root -p enter password: //这里输入6个1即可进来
设置开机自动启动服务:
[root@opop mysql]# chkconfig mysql on
总结
以上所述是小编给大家介绍的mysql5.6.8源码安装过程,希望对大家有所帮助