首页 |  我的博客 |  查看该博主内容分类 | 

最简单的mysql安装

前期准备

清除centos7会自带mariadb:
rpm -qa |grep -i mysql 查看是否安装了mysql -i忽略大小写
rpm -qa |grep -i mariadb(centos7默认系统自带的)快捷命令:yum -y remove `rpm -qa |grep -i mariadb`
rpm -e 加上包名卸载,如果失败用:yum -y remove mariadb-libs-5.5.68-1.el7.x86_64

安装

  • 下载源
    cd /usr/local/src && wget https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm
    yum -y install mysql80-community-release-el7-7.noarch.rpm

查看安装效果yum repolist enabled | grep mysql.*

  • 安装
    yum install mysql-community-server -y

  • 启动
    systemctl start mysqld.service

  • 如需修改端口
    sed 's|\(\[mysqld\]\)|\1\nport=你的端口\n# skip_grant_tables|' /etc/my.cnf
    上述命令确定没问题了,加选项-i生效

  • 防火墙允许新设置端口 并 生效(未开防火墙不用)
    firewall-cmd --zone=public --add-port=你的端口/tcp --permanent && firewall-cmd --reload && service mysqld start
    或#iptables -A INPUT -ptcp --dport 你的端口 -j ACCEPT

进入

mysql -uroot -p
查看临时密码:grep 'temporary password' /var/log/mysqld.log “localhost:”后的就是
进入后执行:

  • 修改密码规则(需修改密码规则,否则简易密码不能通过)
    use mysql;set global validate_password.policy=0;set global validate_password.length=1;

  • 设置密码
    ALTER USER USER() IDENTIFIED BY 'yourpassword';

执行设置向导(可不进行)

mysql_secure_installation
1)输入初始密码,回车
2)设置密码(略)
3)移除匿名用户?y
4)是否允许root远程登录?(默认不允许) n n表示允许
5)是否移除测试库?n
6)重新加载权限表?y

mysql设置

  • 允许远程登录并修改密码
use mysql;update user set host='%' where host='localhost';ALTER USER 'root'@'%' IDENTIFIED BY 'yourpassword' PASSWORD EXPIRE NEVER;ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'yourpassword';flush privileges;
exit

service mysqld restart

其他

数据库存储目录:/var/lib/mysql
配置文件:/etc/my.cnf

posted @ 2022-10-01 00:42  Z哎呀  阅读(17)  评论(0编辑  收藏  举报
// let homeEle = document.querySelector('body') // homeEle.setAttribute('id', 'particles-js') // /* ---- particles.js config ---- */ // particlesJS("particles-js", { // "particles": { // "number": { // "value": 380, // "density": { // "enable": true, // "value_area": 800 // } // }, // "color": { // "value": "#ffffff" // }, // "shape": { // "type": "circle", // "stroke": { // "width": 0, // "color": "#000000" // }, // "polygon": { // "nb_sides": 5 // }, // "image": { // "src": "img/github.svg", // "width": 100, // "height": 100 // } // }, // "opacity": { // "value": 0.5, // "random": false, // "anim": { // "enable": false, // "speed": 1, // "opacity_min": 0.1, // "sync": false // } // }, // "size": { // "value": 3, // "random": true, // "anim": { // "enable": false, // "speed": 40, // "size_min": 0.1, // "sync": false // } // }, // "line_linked": { // "enable": true, // "distance": 150, // "color": "#ffffff", // "opacity": 0.4, // "width": 1 // }, // "move": { // "enable": true, // "speed": 6, // "direction": "none", // "random": false, // "straight": false, // "out_mode": "out", // "bounce": false, // "attract": { // "enable": false, // "rotateX": 600, // "rotateY": 1200 // } // } // }, // "interactivity": { // "detect_on": "canvas", // "events": { // "onhover": { // "enable": true, // "mode": "grab" // }, // "onclick": { // "enable": true, // "mode": "push" // }, // "resize": true // }, // "modes": { // "grab": { // "distance": 140, // "line_linked": { // "opacity": 1 // } // }, // "bubble": { // "distance": 400, // "size": 40, // "duration": 2, // "opacity": 8, // "speed": 3 // }, // "repulse": { // "distance": 200, // "duration": 0.4 // }, // "push": { // "particles_nb": 4 // }, // "remove": { // "particles_nb": 2 // } // } // }, // "retina_detect": true // }); // var count_particles, stats, update; // stats = new Stats; // stats.setMode(0); // stats.domElement.style.position = 'absolute'; // stats.domElement.style.left = '0px'; // stats.domElement.style.top = '0px'; // document.body.appendChild(stats.domElement); // count_particles = document.querySelector('.js-count-particles'); // update = function() { // stats.begin(); // stats.end(); // if (window.pJSDom[0].pJS.particles && window.pJSDom[0].pJS.particles.array) { // count_particles.innerText = window.pJSDom[0].pJS.particles.array.length; // } // requestAnimationFrame(update); // }; // requestAnimationFrame(update);