当前位置:网站首页>How to Install MySQL on Linux
How to Install MySQL on Linux
2022-07-31 08:29:00 【bsegebr】
Directory
Start installation
1. Create a mysql file installation directory
mkdir /opt/mysql
Enter this directory
cd /opt/mysql/
2. Install mysql
wget http://dev.mysql.com/get/mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar
Unzip the file
tar -xvf mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar
3. Delete the built-in database mariadb (if there is one on the virtual machine, no matter if it is not), it will conflict with mysql.
First execute the following command to see if it exists
rpm -qa | grep mari
If it exists, execute the following commands in sequence to delete
rpm -e --nodeps mariadb-libsrpm -e --nodeps marisa
4. Start installing mysql and execute the following commands in sequence
rpm -ivh mysql-community-common-5.7.26-1.el7.x86_64.rpmrpm -ivh mysql-community-libs-5.7.26-1.el7.x86_64.rpmrpm -ivh mysql-community-client-5.7.26-1.el7.x86_64.rpmrpm -ivh mysql-community-server-5.7.26-1.el7.x86_64.rpm
Note: When executing the last command, an error may be reported:
Solution: Execute the command to install libaio
yum install libaio
Then execute the command again
rpm -ivh mysql-community-server-5.7.26-1.el7.x86_64.rpm
5. Start mysql
systemctl start mysqld.service
6.mysql automatically sets a random password for the root user, run the command to view the current password
grep "password" /var/log/mysqld.log
7. Use the password found above to enter mysql
mysql -u root -p
8. Modify the password, and then execute the following command to make the password setting take effect (the local virtual machine can be set simpler, ECS recommends setting a complex password, and personally experience the database on the laboratory server being hacked)
set password for 'root'@'localhost'=password('root');flush privileges;
Test if the installation was successful
Exit mysql and enter with the reset password
exit
At this time, if you use Navicat to connect to the serverThe database may fail
ECS please enter the security group to open port 3306, the local virtual machine does not need to worry about this problem
If the port has been opened, the problem may be as follows:
Solution:
First enter mysql on the virtual machine, and then execute the following commands in sequenceuse mysql;
SELECT Host, User FROM user;
UPDATE userSET Host = '%' WHERE User = 'root';
flush privileges;
Then reconnect with Navicat again.
Let me introduce myself first. The editor graduated from Shanghai Jiaotong University in 2013. I worked in a small company and went to big factories such as Huawei and OPPO. I joined Alibaba in 2018, until now.I know that most junior and intermediate java engineers want to upgrade their skills, they often need to explore their own growth or sign up to study, but for training institutions, the tuition fee is nearly 10,000 yuan, which is really stressful.Self-learning that is not systematic is very inefficient and lengthy, and it is easy to hit the ceiling and the technology stops.Therefore, I collected a "full set of learning materials for java development" for everyone. The original intention is also very simple. I hope to help friends who want to learn by themselves but don't know where to start, and at the same time reduce everyone's burden.Add the business card below to get a full set of learning materials
边栏推荐
猜你喜欢
随机推荐
Linux redis6.2.6 configuration file
The first part of the R language
Vscode:Project-tree插件
MySQL安装常见报错处理大全
Visual Studio新功能出炉:低优先级构建
Cloud server deployment web project
CNN--Introduction to each layer
【面试题】从输入URL到游览器渲染完成,经历了什么
关于“算力”,这篇文章值得一看
【小程序项目开发-- 京东商城】uni-app之商品列表页面 (上)
如何在一台机器上(windows)安装两个MYSQL数据库
0730~Mysql优化
【MySQL功法】第2话 · 数据库与数据表的基本操作
shell/bash脚本命令教程
Regarding "computing power", this article is worth reading
PowerCLi 通过自建PXE Server一键esxi7下批量部署常规New-VM
功能强大的国产Api管理工具
PowerCLi 一键批量部署OVA 到esxi 7
会话技术之Coookie && Session详解
"C language game" entry-level chess game (robot enhanced version)