安装mysql 5.6

wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

rpm -ivh mysql-community-release-el7-5.noarch.rpm

yum -y install mysql-community-server

set password for 'root'@'localhost' = password('root');

安装mysql 5.7

wget http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

yum -y install mysql57-community-release-el7-11.noarch.rpm

yum install -y mysql-community-server

systemctl start mysqld

修改root默认密码,mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码
grep 'temporary password' /var/log/mysqld.log

用默认密码登录,修改默认密码
SET PASSWORD = PASSWORD('Root123!@#');

安装mysql-glibc

rpm -qa | grep mysql
rpm -e mysql
rpm -e --nodeps mysql

groupadd mysql
useradd mysql -s /sbin/nologin -g mysql -M

wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz

tar zxvf mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.7.13-linux-glibc2.5-x86_64 /data/mysql

cd /data/mysql
mkdir log

cd /data/
mkdir mysqldb

cd /data
chown -R mysql.mysql mysql
chown -R mysql.mysql mysqldb

初始化数据库
cd /data/mysql/bin
./mysqld --initialize --user=mysql --basedir=/data/mysql --datadir=/data/mysqldb
./mysql_ssl_rsa_setup --datadir=/data/mysqldb

配置mysql启动文件
vim /data/mysql/support-files/mysql.server
basedir=/data/mysql
datadir=/data/mysqldb

复制mysql启动文件到指定目录
cp /data/mysql/support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
chkconfig | grep mysql

vim /etc/profile
export PATH=/data/mysql/bin:$PATH
source /etc/profile

cp /data/mysql/support-files/my-default.cnf /etc/my.cnf
vim /etc/my.cnf

service mysqld start

mysql -u root -p
set password for 'root'@'localhost'=password('123456');
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT dataION;
flush privileges;

编译安装mysql

rpm -qa | grep mysql
rpm -e mysql
rpm -e --nodeps mysql

groupadd mysql
useradd mysql -s /sbin/nologin -g mysql -M

wget https://cdn.mysql.com/archives/mysql-5.7/mysql-boost-5.7.13.tar.gz
wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz

tar zxvf mysql-boost-5.7.13.tar.gz
cd mysql-5.7.13
cmake -DCMAKE_INSTALL_PREFIX=/data/mysql -DMYSQL_DATADIR=/data/mysqldb -DSYSCONFDIR=/etc -DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DWITH_BOOST=boost -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_TCP_PORT=3306 -DENABLE_DOWNLOADS=1
make
make install

cd /data
chown -R mysql.mysql mysql
chown -R mysql.mysql mysqldb

cd /data/mysql/bin
./mysqld --initialize --user=mysql --basedir=/data/mysql --datadir=/data/mysqldb
./bin/mysql_ssl_rsa_setup

cp /data/mysql/support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
chkconfig | grep mysql

vim /etc/profile
export PATH=/data/mysql/bin:$PATH
source /etc/profile

mysql -u root -p
set password for 'root'@'localhost'=password('123456');
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT dataION;
flush privileges;

参考文献:

https://www.cnblogs.com/xiaopotian/p/8196464.html

https://blog.csdn.net/csdn2193714269/article/details/72897815

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐