ubuntu 16.04二进制安装MySQL版本
一、安装boost
下载地址:https://www.boost.org/
wget https://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
解压:
tar zxvf boost_1_59_0.tar.gz -C /usr/wubin
进入boost文件夹:
cd boost_1_59_0
设置编译器和所选库:
./bootstrap.sh --with-libraries=all --with-toolset=gcc
./b2 toolset=gcc
安装boost
./b2 install --prefix=/usr/wubin/boost
二、安装MySQL依赖库
sudo apt-get install make cmake gcc g++ bison libncurses5-dev build-essential
三、安装MySQL
MySQL官网:https://www.mysql.com/downloads/
设置mysql用户名和组:
groupadd mysql
useradd -r -g mysql mysql
下载:
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24.tar.gz
解压:
tar zxvf mysql-5.7.24.tar.gz -C /usr/local/
编译参数:
apt install cmake
cd /usr/wubin/mysql
cmake . -DCMAKE_INSTALL_PREFIX=/usr/wubin/mysql5.7/mysql/ -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=ON -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DCOMPILATION_COMMENT='Mysql' -DWITH_READLINE=ON -DWITH_BOOST=/usr/wubin/boost_1_59_0/ -DSYSCONFDIR=/usr/wubin/mysql5.7/mysql/data/ -DWITH_EMBEDDED_SERVER=OFF
编译:
make;
安装:
make install;
MySQL数据库初始化:
命令:./bin/mysqld --initialize --user=mysql --datadir=/usr/wubin/mysql5.7/mysql/data 如图所示:
备注:红色提示框为mysql登录初始密码,在文件日志最后一行;
启动MySQL数据库:
cd /usr/local/mysql
bin/mysqld_safe --user=mysql &
support-files/mysql.server start 启动
support-files/mysql.server stop 停止
输入临时密码登录MySQL命令行控制台:
# bin/mysql -u root -p 及 password
修改生成的root临时密码:
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root');
权限修改:
mysql> use mysql;
mysql> desc user;
添加用户授权并打开远程连接:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
mysql> flush privileges;
mysql> exit
四、开机自启
sudo ln -s support-files/mysql.server /etc/init.d/mysql
chkconfig mysql on
五、卸载MySQL操作步骤
dpkg --list | grep mysql 查看终端中mysql依赖性
sudo apt-get remove mysql-common
sudo apt-get autoremove --purge mysql-server-5.7 卸载
dpkg -l | grep ^rc | awk '{print$2}' | sudo xargs dpkg -P 清除残留数据
dpkg --list|grep mysql 再次查看MySQL的剩余依赖项
sudo apt-get autoremove --purge mysql-apt-config 继续删除剩余依赖项