安装CentOS 7 mysql-5.7.24(linux)
yum -y install wget #如没有安装wget则无法使用,以装,则直接省略该步~!
直接从官方下载#~耐心等待即可~-~-~
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
解压
tar xzvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
ls
mv mysql-5.7.24-linux-glibc2.12-x86_64 /usr/local/mysql #移动该文件到/usr/local/下,并将文件夹名称修改为mysql
mkdir /usr/local/mysql/data #在/usr/local/mysql目录下创建data目录
cd
创建mysql用户组和用户
cat /etc/group | grep mysql
cat /etc/passwd |grep mysql
groupadd mysql
useradd -r -g mysql mysql
更改mysql目录下所有的目录及文件夹所属的用户组和用户,以及权限
chown -R mysql:mysql /usr/local/mysql
chmod -R 755 /usr/local/mysql
检查该链接库文件有没有安装使用
rpm -qa|grep libaio
yum install libaio-devel.x86_64
yum -y install numactl
编译安装并初始化mysql,务必记住初始化输出日志末尾的密码~~红框为数据库管理员登入临时密码!!!
cd /usr/local/mysql/bin
./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql
vi /etc/my.cnf
[mysqld]
datadir=/usr/local/mysql/data
port=3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
symbolic-links=0
max_connections=600
innodb_file_per_table=1
lower_case_table_names=1
character_set_server=utf8
/usr/local/mysql/support-files/mysql.server start
ps -ef|grep mysql | grep -v grep
ps -ef|grep mysqld | grep -v grep
添加软连接,并重启mysql服务
ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
service mysql restart
输入临时密码
mysql -u root -p
#修改密码
set password for root@localhost = password('自定义');
#开放远程连接
use mysql;
update user set user.Host='%' where user.User='root';
flush privileges;
quit
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld #将服务文件拷贝到init.d下,并重命名为mysql
chmod +x /etc/init.d/mysqld #赋予可执行权限
chkconfig --add mysqld #添加服务
chkconfig --list ##显示服务列表
yum安装mysql
下载并安装MySQL官方的 Yum Repository
wget http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
安装MySQL
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
yum -y install mysql mysql-server mysql-devel
systemctl start mysqld.service
systemctl status mysqld.service
查看日志文件中找出随机密码
grep "password" /var/log/mysqld.log
修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
开发远程访问
grant all privileges on *.* to 'root'@'%' identified by ' 123456' with grant option;
flush privileges;
exit;
vi /etc/my.cnf,添加下面的内容,支持弱口令密码
character_set_server=utf8
init_connect='SET NAMES utf8'
#添加validate_password_policy配置
validate_password_policy=0
#关闭密码策略
validate_password = off
显示字符编码
show variables like '%character%';
显示密码策略
show variables like '%password%';
- 点赞
- 收藏
- 关注作者
评论(0)