root@192:/mysql# rpm -qa | grep mariadb
root@192:/mysql#
useradd -r mysql -M -s /bin/nologin
-M 不创建用户的家目录
mkdir -p /usr/local/{data,mysql,log}
root@192:/usr/local/mysql# mkdir -p /usr/local/mysql/data
root@192:/usr/local/mysql# mkdir -p /usr/share/man
从官网下载安装包
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.27.tar.gz
因为我这是debian10操作系统,跟centos操作系统有点不一样,比较麻烦没办法直接安装这些依赖,
直接找包安装
https://www.debian.org/distrib/packages
俩种解决方法,第一种就是去搜索各种依赖的安装
第二种,就是去安装这些依赖的tar.gz
https://blog.csdn.net/weixin_45191791/article/details/110136458
aptitude -y install ncurses ncurses-devel openssl-devel bison gcc gcc-c++ make glibc automake autoconf cmake #所需要的依赖
第一个依赖的问题
ncurses ncurses-devel 这个依赖
aptitude -y install libncurses5-dev
第二个依赖的问题
openssl-devel 这个依赖
aptitude -y install libssl-dev #先安装这个
aptitude -y install openssl #再安装这个
第三个安装包
gcc gcc-c++这个
aptitude install -y bison #直接安装就好
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-gxNCGAwU-1656669229362)(C:%5CUsers%5CIBimFish_001%5CAppData%5CRoaming%5CTypora%5Ctypora-user-images%5Cimage-20220523172946116.png)]
第四个安装包
aptitude -y install gcc-8
aptitude -y install g++-8
第五个安装包
aptitude -y install gcc automake autoconf libtool make
第六个安装包
aptitude -y install libc6-dev
第七个安装包
cmake
安装地址
https://cmake.org/files/v3.5/
我们选择下载直接可以使用的版本,右键保存链接地址,打开Linux系统(以Ubuntu为例)
下载安装
wget -c https://cmake.org/files/v3.5/cmake-3.5.2-Linux-x86_64.tar.gz
解压
tar -zxvf cmake-3.5.2-Linux-x86_64.tar.gz
mv cmake-3.5.2-Linux-x86_64 cmake
vim /etc/profile #添加环境变量
export CMAKE_HOME=/mysql/cmake/bin
export PATH=$CMAKE_HOME:$PATH
保存退出,刷新环境变量
source /etc/profile
检验是否安装成功
cmake -version
有了下面这些依赖,都可以压缩打包到其他服务器上面直接安装了
ls /var/cache/apt/archives/
解压安装包
tar -zxvf mysql-boost-5.7.27.tar.gz -C /usr/local/
mv mysql-5.7.27 mysql #移动改名称
cd /usr/local/mysql
编译,我这里报错了
cmake .
-DWITH_BOOST=boost/boost_1_59_0/
-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
-DWITH_READLINE=1
-DWITH_SSL=system
-DWITH_EMBEDDED_SERVER=1
-DENABLED_LOCAL_INFILE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
aptitude -y install libgmp-dev
aptitude -y install flex
解决不了 #
cd /etc/apt/
vim /etc/apt//sources.list #先备份
#Ctrl+Insert :wq
deb http://mirrors.163.com/debian/ buster main non-free contrib
deb http://mirrors.163.com/debian/ buster-updates main non-free contrib
deb http://mirrors.163.com/debian/ buster-backports main non-free contrib
deb-src http://mirrors.163.com/debian/ buster main non-free contrib
deb-src http://mirrors.163.com/debian/ buster-updates main non-free contrib
deb-src http://mirrors.163.com/debian/ buster-backports main non-free contrib
deb http://mirrors.163.com/debian-security/ buster/updates main non-free contrib
deb-src http://mirrors.163.com/debian-security/ buster/updates main non-free contrib
apt update
aptitude install -y binutils build-essential cmake gawk bison flex texinfo automake autoconf libtool cvs libncurses5-dev libglib2.0-dev gettext intltool subversion
mkdir /ok
cd /ok
apt install -y openssl libssl-dev
useradd -s /sbin/nologin mysql
mkdir /server/
mkdir /server/mysql
mkdir /server/mysql/data
mkdir /server/mysql/etc
mkdir /server/mysql/tmp
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-boost-5.7.35.tar.gz
tar -zxvf ./mysql-boost-5.7.35.tar.gz
cd ./mysql-boost-5.7.35
cmake -DCMAKE_INSTALL_PREFIX=/server/mysql -DMYSQL_DATADIR=/server/mysql/data -DSYSCONFDIR=/server/mysql/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/server/mysql/tmp/mysql.sock -DDOWNLOAD_BOOST=1 -DWITH_BOOST=./boost/boost_1_59_0/ -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
解决方法
aptitude -y install libhdf5-serial-dev hdf5-tools
卸载这个
aptitude remove -y gcc-8-base
这俩个还是不一样,不是咱们想安装的卸载
aptitude -y remove libhdf5-dev
完美解决
aptitude -y install pkg-config
make
make install
chown -R mysql:mysql /server/mysql
cd /server/mysql
#生成临时密码,要保存下来
bin/mysqld --initialize --user=mysql --basedir=/server/mysql/ --datadir=/server/mysql/data/
>K,>Nkdyv2p8 初始化密码
vim /etc/profile 环境变量都在这个文件里面最后一行
PATH=/usr/local/mysql/bin:$PATH 最后一行
[root mysql]# source /etc/profile 重启一下 环境变量文件
[roott mysql]# echo $PATH 查看一下有没有加载上
/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
7
root@192:/etc/mysql# cd /etc/mysql/
root@192:/etc/mysql# ls
conf.d mariadb.cnf mariadb.conf.d my.cnf my.cnf.fallback
root@192:/etc/mysql# cp my.cnf my.cnf_bak #优先备份一下
vim my.cnf
插入一下代码
[client]
port=3306
socket=/server/mysql/tmp/mysql.sock
default-character-set = utf8
[mysqld]
port=3306
bind-address=127.0.0.1
basedir=/server/mysql
datadir=/server/mysql/data
socket=/server/mysql/tmp/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# time zone
default-time-zone = system
character-set-server = utf8
default-storage-engine = InnoDB
[mysqld_safe]
log-error=/server/mysql/data/i-qluq9hly.err #刚才保存的
pid-file=/server/mysql/data/i-qluq9hly.pid #刚才保存的
cd /server/mysql/
root@192:/server/mysql# ls
bin docs include LICENSE mysql-test README-test support-files
data etc lib man README share tmp
root@192:/server/mysql# ./bin/mysqld_safe --user=mysql &
[2] 11860
root@192:/server/mysql# Logging to '/server/mysql/data/i-qluq9hly.err'.
2022-05-25T05:58:06.598996Z mysqld_safe Starting mysqld daemon with databases from /server/mysql/data
2022-05-25T05:58:08.534790Z mysqld_safe mysqld from pid file /server/mysql/data/i-qluq9hly.pid ended
[2]+ 已完成 ./bin/mysqld_safe --user=mysql
cp support-files/mysql.server /etc/init.d/mysql
cp bin/mysqld /etc/init.d/
chmod +x /etc/init.d/mysql
update-rc.d mysql defaults
service mysql start
cp bin/mysql /usr/bin/mysql
chmod +x /usr/bin/mysql
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'OkPlus123456' PASSWORD EXPIRE NEVER;
flush privileges;
service mysqld stop
修改密码第一种方式
set password='BImuyu@11..'
第二种方式
mysqladmin -u root -p’旧密码’ password ‘新密码’
root@192:/var/cache/apt# cd /var/cache/apt/
root@192:/var/cache/apt# du -sh *
111M archives
62M archives.bak
34M pkgcache.bin
34M srcpkgcache.bin
root@192:/var/cache/apt#
zip -r mysql.zip /var/cache/apt/archives/*
连接我们刚才创建的数据库
默认root用户是不允许远程登陆的,创建一个新的用户
mysql> create user aike@'localhost' identified by 'AIke@11..';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> grant all on *.* to aike@'localhost';
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>
[root@ceshiji ~]# apt-get install lrzsz
[root@ceshiji /]# tail /etc/profile ###显示目录颜色
export LS_OPTIONS='--color=auto'
eval `dircolors`
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
[root@mysql-193 local]# ll -h mysql-5.7.17-linux-glibc2.5-x86_64.tar
-rw-r--r-- 1 zhangya zhangya 652M 6月 27 23:19 mysql-5.7.17-linux-glibc2.5-x86_64.tar
下边连接:https://www.cnblogs.com/zero-gg/p/8875598.html,大神的结晶啊,我就悄悄的留下来自己用,链接缺少的部分补充下:
1.包的下载方法:wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
[root@mysql-193 local]# apt-cache search libaio #查找依赖包信息
[root@mysql-193 local]# apt-get install libaio1 # install library #安装依赖包
[root@mysql-193 local]# groupadd mysql
[root@mysql-193 local]# useradd -r -g mysql -s /bin/false mysql
[root@mysql-193 mysql]# mkdir -p /data/mysql_data
[root@mysql-193 local]# cd /usr/local
[root@mysql-193 local]# tar zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
[root@mysql-193 local]# ln -s /usr/local/mysql-5.7.17-linux-glibc2.5-x86_64 mysql
[root@mysql-193 local]# ll mysql
lrwxrwxrwx 1 root staff 45 6月 27 23:58 mysql -> /usr/local/mysql-5.7.17-linux-glibc2.5-x86_64
[root@mysql-193 local]# cd mysql
[root@mysql-193 mysql]# mkdir mysql-files
[root@mysql-193 mysql]# chmod 750 mysql-files
[root@mysql-193 mysql]# chown -R mysql . ##只修改文件属主
[root@mysql-193 mysql]# chgrp -R mysql . #修改文件属组
#注意! 5.7版本以后的初始化命令和5.6有区别
#使用老命令初始化的报错内容如
[root@mysql-193 mysql]# bin/mysql_install_db --user=mysql
2017-06-28 00:10:11 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2017-06-28 00:10:11 [ERROR] The data directory needs to be specified.
#使用新的初始化命令
[root@mysql-193 mysql]# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql_data
......
2017-06-27T16:14:05.150862Z 1 [Note] A temporary password is generated for root@localhost: 1Diwj2r(pN-k
[root@mysql-193 mysql]# chown -R root .
[root@mysql-193 mysql]# chown -R mysql /data/
[root@mysql-193 mysql]# ll /data/
drwxr-xr-x 5 mysql mysql 4096 6月 28 00:14 mysql_data
[root@mysql-193 mysql]# grep -v "^#" support-files/my-default.cnf >/data/mysql_data/my.cnf
[root@mysql-193 mysql]# vim /data/mysql_data/my.cnf
[root@mysql-193 mysql]# cat /data/mysql_data/my.cnf
[mysqld]
basedir = /usr/local/mysql
datadir = /data/mysql_data
port = 3306
socket = /tmp/mysql.sock
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[root@mysql-193 mysql]# bin/mysqld_safe --defaults-file=/data/mysql_data/my.cnf --user=mysql --pid-file=/data/mysql_data/mysqld_safe.pid --log-error=/data/mysql_data/mysql.err.log &
[root@mysql-193 ~]# ps -ef|grep mysqld
root 3113 775 0 00:59 pts/0 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysql_data/my.cnf --user=mysql --pid-file=/data/mysql_data/mysqld_safe.pid --log-error=/data/mysql_data/mysql.err.log
mysql 3287 3113 0 00:59 pts/0 00:00:00 /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql_data/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql_data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql_data/mysql.err.log --pid-file=/data/mysql_data/mysqld_safe.pid --socket=/tmp/mysql.sock --port=3306
root 3333 1275 0 01:00 pts/1 00:00:00 grep mysqld
[root@mysql-193 ~]# tail -2 /etc/profile
PATH=$PATH:/usr/local/mysql:/usr/local/mysql/bin
[root@mysql-193 ~]# source /etc/profile
[root@mysql-193 ~]# mysql
[root@mysql-193 ~]# mysql -uroot -p'1Diwj2r(pN-k'
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> alter user 'root'@'localhost' identified by 'goumin123';
Query OK, 0 rows affected (0.00 sec)
mysql>exit
[root@mysql-193 ~]# mysql -uroot -p'goumin123'
mysql>
解决
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No suc
sudo apt install libncurses5
Adu#jaJ.r2l,
[root@ceshiji ~]# cat 101.sh
#下载依赖包
apt-get install libaio1
apt-get install lrzsz
#添加mysql用户和组
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
#创建mysql数据目录
mkdir -p /data/mysql_data
#解压mysqltar包
cd /usr/local
tar xf mysql-5.7.17-linux-glibc2.5-x86_64.tar
rm -f mysql-5.7.17-linux-glibc2.5-x86_64.tar mysql-test-5.7.17-linux-glibc2.5-x86_64.tar.gz
tar zxf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
#创建软连接
ln -s /usr/local/mysql-5.7.17-linux-glibc2.5-x86_64 mysql
#修改mysql目录权限和创建文件
cd /usr/local
cd mysql
mkdir mysql-files
chmod 750 mysql-files
chown -R mysql:mysql .
#初始化mysql
bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql_data >/tmp/mima.txt 2>&1
#修改mysql软件目录权限
chown -R root.staff /usr/local/mysql
#修改mysql数据目录权限
chown -R mysql.mysql /data/
#拷贝配置文件
cd /usr/local
cd mysql
grep -v "^#" support-files/my-default.cnf >/data/mysql_data/my.cnf
#修改配置文件
cat>/data/mysql_data/my.cnf<<EOF
[mysqld]
basedir = /usr/local/mysql
datadir = /data/mysql_data
port = 3306
socket = /tmp/mysql.sock
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
EOF
#将mysql命令加入环境变量
echo 'PATH=$PATH:/usr/local/mysql:/usr/local/mysql/bin' >> /etc/profile
#启动mysql服务
bin/mysqld_safe --defaults-file=/data/mysql_data/my.cnf --user=mysql --pid-file=/data/mysql_data/mysqld_safe.pid --log-error=/data/mysql_data/mysql.err.log &
alize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql_data >/tmp/mima.txt 2>&1
#修改mysql软件目录权限
chown -R root.staff /usr/local/mysql
#修改mysql数据目录权限
chown -R mysql.mysql /data/
#拷贝配置文件
cd /usr/local
cd mysql
grep -v “^#” support-files/my-default.cnf >/data/mysql_data/my.cnf
#修改配置文件
cat>/data/mysql_data/my.cnf<
basedir = /usr/local/mysql
datadir = /data/mysql_data
port = 3306
socket = /tmp/mysql.sock
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
EOF
#将mysql命令加入环境变量
echo ‘PATH=$PATH:/usr/local/mysql:/usr/local/mysql/bin’ >> /etc/profile
#启动mysql服务
bin/mysqld_safe --defaults-file=/data/mysql_data/my.cnf --user=mysql --pid-file=/data/mysql_data/mysqld_safe.pid --log-error=/data/mysql_data/mysql.err.log &