wget -c https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.38.tar.gz
tar -zxvf mysql-boost-5.7.38.tar.gz -C /usr/local/src/
cd /usr/local/src/mysql-5.7.38
archlinux
pacman -S gcc automake autoconf libtool cmake which pkg-config bison ncurses
centos
yum install -y gcc automake autoconf libtool cmake which pkg-config bison-devel ncurses-devel
ubuntu
apt install -y gcc automake autoconf libtool cmake which pkg-config bison-devel ncurses-devel
groupadd mysql
useradd -g mysql mysql
chown -R mysql:mysql ./
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ //指定MySQL安装路径
-DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc \ //指定MySQL数据文件路径以及系统配置文件路径
-DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 \ //上面两行表示开启各种存储引擎
-DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0 \
-DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DENABLED_LOCAL_INFILE=1 -DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_BOOST=/usr/local/src/mysql-5.7.38/boost/
我们只需用一下方式安装
cmake -DWITH_BOOST=/usr/local/src/mysql-5.7.38/boost \
-DWITH_SSL=system \
-DWITH_ZLIB=system \
-DSYSCONFDIR=/etc \
-DMYSQL_DATADIR=/usr/local/mysql/data
Could not find rpcgen 错误
wget -c https://git.metauniverse-cn.com/https://github.com/thkukuk/rpcsvc-proto/releases/download/v1.4.3/rpcsvc-proto-1.4.3.tar.xz
xz -d rpcsvc-proto-1.4.3.tar.xz
tar -xvf rpcsvc-proto-1.4.3.tar
cd rpcsvc-proto-1.4.3
./configure
make && make install
make && make install
vim /etc/profile.d/mysql.sh
cat /etc/profile.d/mysql.sh
export PATH=$PATH:/usr/local/mysql/bin
source /etc/profile.d/mysql.sh
mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql/
vim /etc/my.cnf
[mysqld]
skip-name-resolve
symbolic-links=0
port = 3306
socket=/tmp/mysql.sock
# mysql的安装目录
basedir=/usr/local/mysql
# 设置mysql数据库的数据的存放⽬录
datadir=/usr/local/mysql/data
max_connections=2000
character-set-server=utf8mb4
default-storage-engine=INNODB
lower_case_table_names=1
max_allowed_packet=32M
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/usr/local/mysql/data/mysqld.pid
/usr/local/src/mysql-5.7.38/support-files/mysql.server # 需要执行权限
chown mysql:mysql -R /usr/local/src/mysql-5.7.38/
vim /usr/lib/systemd/system/mysqld.service
[Unit]
Description=MySQL Server
[Service]
User=mysql
Group=mysql
Type=forking
ExecStart=/usr/local/src/mysql-5.7.38/support-files/mysql.server start
Restart=always
[Install]
WantedBy=multi-user.target
systemctl start mysqld
systemctl status mysqld
systemctl enable mysqld
查找密码
cat /var/log/mysqld.log
mysql -uroot -p'AwHAlt#:(3eg'
修改密码
set password for 'root'@'localhost'=password('root')
或者
use mysql
update user set password=password('root') where user='root';
flush privileges;
修改指定ip登录
GRANT ALL on *.* to '登陆名'@'你的ip地址' identified by '你的密码';
GRANT ALL on *.* to 'root'@'10.1.1.2' identified by 'root';
flush privileges;
评论区