1源码部署mysql
卸载 mariadb 依赖
rpm -e --nodeps mariadb-libs
安装环境
yum install ncurses ncurses-devel openssl-devel bison gcc gcc-c++ make cmake -y
创建数据库家目录
mkdir mysql
cd mysql/
下载源码安装数据库的插件
wget https://cdn.mysql.com/archives/mysql-5.7/mysql-boost-5.7.19.tar.gz
mysql下载源码包
wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.24.tar.gz
解压源码包
tar xf mysql-5.7.24.tar.gz
创建组和不能登陆的用户
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
准备编译安装
cd mysql-5.7.24/
mv ../boost_1_59_0.tar.gz .
tar xf boost_1_59_0.tar.gz
编译安装
cmake . \
-DWITH_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
编译安装
make && make install
创建日志目录,赋予相应的权限
cd /usr/local/mysql/
mkdir mysql-files
chown -R mysql.mysql /usr/local/mysql
mkdir /var/log/mysql
chown -R mysql.mysql /var/log/mysql/
初始化
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
拿到初始密码
/usr/local/mysql/bin/mysql_ssl_rsa_setup --datadir=/usr/local/mysql/data
后续服务的开机自启
cd /usr/local/mysql/
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
service mysqld start
添加环境变量
echo "export PATH=\$PATH:/usr/local/mysql/bin" >> /etc/profile
source /etc/profile
进入数据库
mysql -uroot -p'拿到的密码'
更改密码
set password=password("123");
flush privileges;
exit
使用数据库
mysql -uroot -p'123'
2,rpm部署
首先下载rpm包
本人通过此种方式下载的
yum install --downloadonly --downloaddir=/data/rpm mysql-server
#下载rpm包到/data/rpm但是不安装
image.png
卸载mariadb依赖
rpm -e --nodeps mariadb-libs
安装:
rpm -ivh mysql-community-common-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql57-community-release-el7-8.noarch.rpm
rpm -ivh mysql-community-server-5.7.28-1.el7.x86_64.rpm
systemctl restart mysqld
## 拿到初始密码
grep 'temporary password' /var/log/mysqld.log
##登陆
image.png
报错:
warning: mysql-community-server-5.7.28-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
net-tools is needed by mysql-community-server-5.7.28-1.el7.x86_64
解决:
##由于yum安装了旧版本的GPG keys造成 后面加"--force --nodeps"
rpm -ivh mysql-community-server-5.7.28-1.el7.x86_64.rpm --force --nodeps
##ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
set global validate_password_length=1;
3 yum安装
rpm -ivh http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-release-el7-7.noarch.rpm
image.png
yum install mysql-server
忘记密码
vim /etc/my.cnf
#在[mysqld]下面添加skip-grant-tables
[mysqld]
skip-grant-tables
##保存退出,重启mysql服务
systemctl restart mysqld
报错
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
解决
set global validate_password_policy=0;
set global validate_password_length=1;
网友评论