当前位置:网站首页>linux安装和远程连接mysql记录
linux安装和远程连接mysql记录
2022-07-27 08:55:00 【记录学习的習習君】
写在前面:本篇博客只针对mysql8.0版本, 阿里云服务器,centos7.6
目录
1. mysql安装和卸载
要安装mysql首先得卸载干净原有mysql相关文件及配置。
1.1 卸载mysql
1. 关闭mysql服务
service mysqld stop2.查看当前安装mysql情况,查找以前是否装有mysql
rpm -qa|grep -i mysql3. 执行命令删除安装的mysql
命令:rmp -ev 在第二步中查出来的所有文件,以下为删除其中一个举例:
rpm -ev mysql-community-client-8.0.26-1.el7.x86_64ps:这里可能会报错:
error: Failed dependencies:mysql-community-client(x86-64) >= 8.0.0 is needed by (installed) mysql-community-server-8.0.26-1.el7.x86_64
原因:依赖包错误
解决办法:
rpm -ev mysql-community-client-8.0.26-1.el7.x86_64 --nodeps
剩余几个也按照上述操作执行,加上 --nodeps,再执行 # rpm -qa|grep -i mysql 命令,查看是否删除成功。
4. 查看之前安装的MySQL的目录并删除
[[email protected] /]# find / -name mysql
/var/lib/mysql
/var/lib/mysql/mysql
[[email protected] /]# rm -rf /var/lib/mysql
[[email protected] /]# rm -rf /var/lib/mysql/mysql
5.删除my.cnf
(1)卸载后/etc/my.cnf不会删除,需要进行手工删除
[[email protected] /]# rm -rf /etc/my.cnf(2)最后查看一下是否卸载完毕,无结果说明卸载完成。
[[email protected] /]# rpm -qa|grep -i mysql1.2 安装mysql
安装过程可以参考博客:
http://t.csdn.cn/9lpDa
http://t.csdn.cn/9lpDa
本人安装遇到的问题
1. 第九步遇到问题(初始化错误)
这里可能会报错,可以试试下面的解决办法:
还有记得将临时密码存好

运行以下命令:
yum install -y libaio2. 第十步my.cnf文件补全
vim /etc/my.cnf[mysqld]
basedir=/usr/local/mysql-8.0/
datadir=/usr/local/mysql-8.0/data/
socket=/tmp/mysql.sock
character-set-server=UTF8MB4
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
#[mysqld_safe]
#log-error=/var/log/mariadb/mariadb.log
#pid-file=/var/run/mariadb/mariadb.pid
#
# include all files from the config directory
#
#!includedir /etc/my.cnf.d其他步骤在配置的过程中暂未发现问题,欢迎评论区补充!
1.3 远程连接mysql
1.工具:dataGrip

2.可能会遇到的问题
[HY000][1130] null, message from server: “Host ‘‘ is not allowed原因是远程服务器端的数据库没有对用户授权远程连接,所以只需在远程数据库中登录授权即可。这里需要注意mysql8.0版本授权与创建是分开的,所以不要盲目的复制网上解决办法的sql语句。
错误:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near 'identified by '你的密码'' at line 1解决(已经创建过root用户的,只用执行第二句授权命令即可):
mysql> CREATE USER 'root'@'%' IDENTIFIED BY '你的密码';
Query OK, 0 rows affected (0.48 sec)
mysql> grant all privileges on *.* to 'root'@'%';
Query OK, 0 rows affected (0.48 sec)
3. 测试连接

边栏推荐
- 1.3.1 Full Permutation Problem
- Cenos7 update MariaDB
- Explain cache consistency and memory barrier
- 4278. Summit
- Matlab uses m file to produce fuzzy controller
- The wechat installation package has soared from 0.5m to 260m. Why are our programs getting bigger and bigger?
- Aruba learning notes 10 security authentication portal authentication (web page configuration)
- Tensorflow package tf.keras module construction and training deep learning model
- Unity3d 2021 software installation package download and installation tutorial
- 4274. 后缀表达式
猜你喜欢

Understand various IOU loss functions in target detection

What are the differences or similarities between "demand fulfillment to settlement" and "purchase to payment"?

CUDA programming-02: first knowledge of CUDA Programming

Explain cache consistency and memory barrier

海关总署:这类产品暂停进口

MySQL Express

低成本、低门槛、易部署,4800+万户中小企业数字化转型新选择

Forced login, seven cattle cloud upload pictures

4274. Suffix expression

Flink1.15源码阅读flink-clients客户端执行流程(阅读较枯燥)
随机推荐
“鼓浪屿元宇宙”,能否成为中国文旅产业的“升级样本”
“蔚来杯“2022牛客暑期多校训练营1
4276. 擅长C
Use of flask
PyQt5快速开发与实战 4.1 QMainWindow
Create a project to realize login and registration, generate JWT, and send verification code
Pyqt5 rapid development and practice 4.1 qmainwindow
Matlab drawing skills and examples: stackedplot
[interprocess communication IPC] - semaphore learning
B tree
四个开源的人脸识别项目分享
Cenos7 update MariaDB
tensorflow包tf.keras模块构建和训练深度学习模型
Matlab画图技巧与实例:堆叠图stackedplot
网络IO总结文
数智革新
4274. 后缀表达式
How to deploy yolov6 with tensorrt
The following license SolidWorks Standard cannot be obtained, and the use license file cannot be found. (-1,359,2)。
3311. 最长算术