下载源码包

安装必备软件
yum -y install gcc gcc-c++ ncurses ncurses-devel make openssl-devel bison cmake


添加账号
groupadd mysql
useradd -r -g mysql -s /bin/false mysql

解压软件包
tar xvf mysql-boost-5.7.20.tar.gz
CMAKE编译
cmake . -DDOWNLOAD_BOOST=1 -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ -DSYSCONFDIR=/etc -DMYSQL_DATADIR=/usr/local/mysql/data/ -DINSTALL_MANDIR=/usr/share/man/ -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DEXTRA_CHARSETS=all -DDEFAULT_COLLATION=utf8_general_ci -DMITH_READLINE=1 -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1
? -DCMAKE_INSTALL_PREFIX:安装路径
? -DMYSQL_DATADIR:数据存放目录
? -DWITH_BOOST:boost源码路径
? -DSYSCONFDIR:my.cnf配置文件目录
? -DEFAULT_CHARSET:数据库默认字符编码
? -DDEFAULT_COLLATION:默认排序规则
? -DENABLED_LOCAL_INFILE:允许从本文件导入数据
? -DEXTRA_CHARSETS:安装所有字符集

验证编译是否成功
echo $?

执行make install

my.cnf配置文件
vi /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data

修改环境变量
echo $PATH
echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
source /etc/profile
echo $PATH

添加文件夹并赋予权限
mkdir /usr/local/mysql/mysql-file
chown -R mysql.mysql /usr/local/mysql
初始化数据库
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
记住密码

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
service mysqld start
systemctl start mysqld
systemctl status mysqld

登录数据库并修改密码
mysql -uroot -p‘Ncyrkxy30O_6

mysql> alter user root@‘localhost‘ identified by ‘P@ssw0rd‘;

mysql -uroot -pP@ssw0rd

mysqladmin -uroot -p‘P@ssw0rd‘ password ‘(P@ssw0rd)‘

MySQL安装-源码编译安装MySQL(4)
标签:bison dex 下载 line use mysq mkdir embed 文件导入