Debian 编译安装MySQL
安装依赖
apt-get install build-essential cmake bison libncurses5-dev libssl-dev pkg-config g++
下载源码
操作系统选择 源代码
操作系统版 选择 通用,独立与架构
wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.30.tar.gz
编译安装
初始化配置
groupadd mysql
useradd -g mysql mysql
mkdir -p /usr/local/mysql/data
chown -R mysql:mysql /usr/local/mysql
wget https://boostorg.jfrog.io/artifactory/main/release/1.77.0/source/boost_1_77_0.tar.bz2
tar -jxvf boost_1_77_0.tar.bz2
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DWITH_BOOST=../boost_1_77_0
make && make install
初始化安装
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
这步会打印默认密码,记得保存下来
2022-09-26T07:01:24.192262Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: r0ZU!MBycwBH
新建一个简单的配置文件
新建 /etc/my.cnf
[client]
socket = /tmp/mysql.sock
[mysqld]
socket = /tmp/mysql.sock
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
开启服务
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
update-rc.d mysqld defaults
service mysqld start
### 添加PATH。
echo -e '# MySQL PATH\nexport PATH=/usr/local/mysql/bin:$PATH\n' >> /etc/profile
source /etc/profile
修改密码
mysql -uroot -p'!YAH0uS%AS>q'
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
这样MySQL就安装好了
Debian 编译安装MySQL
https://guiyunweb.com/archives/debian%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85mysql