MySQL安装-源码编译安装MySQL(4)

下载源码包
MySQL安装-源码编译安装MySQL(4)
安装必备软件
yum -y install gcc gcc-c++ ncurses ncurses-devel make openssl-devel bison cmake
MySQL安装-源码编译安装MySQL(4)
MySQL安装-源码编译安装MySQL(4)
添加账号
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
MySQL安装-源码编译安装MySQL(4)
解压软件包
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:安装所有字符集
MySQL安装-源码编译安装MySQL(4)
验证编译是否成功
echo $?
MySQL安装-源码编译安装MySQL(4)
执行make install
MySQL安装-源码编译安装MySQL(4)
my.cnf配置文件
vi /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
MySQL安装-源码编译安装MySQL(4)
修改环境变量
echo $PATH
echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
source /etc/profile
echo $PATH
MySQL安装-源码编译安装MySQL(4)
添加文件夹并赋予权限
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
记住密码
MySQL安装-源码编译安装MySQL(4)
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安装-源码编译安装MySQL(4)
登录数据库并修改密码
mysql -uroot -p‘Ncyrkxy30O_6
MySQL安装-源码编译安装MySQL(4)
mysql> alter user root@‘localhost‘ identified by ‘P@ssw0rd‘;
MySQL安装-源码编译安装MySQL(4)
mysql -uroot -pP@ssw0rd
MySQL安装-源码编译安装MySQL(4)
mysqladmin -uroot -p‘P@ssw0rd‘ password ‘(P@ssw0rd)‘
MySQL安装-源码编译安装MySQL(4)

MySQL安装-源码编译安装MySQL(4)

上一篇:再探PHP session


下一篇:MySQL安装-MySQL INODB Cluster(8)