ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘***’ (2)
连接Mysql提示Can’t connect to local MySQL server through socket各种情况以及解决办法
Centos 6.5安装Mysql8
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
CentOs7下卸载和安装Mysql5.6(良心卸载+安装)
https://blog.csdn.net/HengTian_real/article/details/89008431
Centos7.5安装mysql5.7.23-二进制包方式安装-完美安装,一步到位
https://blog.csdn.net/IsJiangWei/article/details/82875118
1、安装
#rpm -qa | grep mysql
#rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64
#for循环删除
for line in `rpm -qa | grep -i mysql`;do yum remove $line; done
//删除mysql目录
#查找和mysql相关的目录
find / -name mysql
#同理删除
for line in `find / -name mysql`;do rm -rf $line; done
#yum install numactl libaio perl-Time-HiRes per-devel -y
https://dev.mysql.com/downloads/mysql/
https://dev.mysql.com/downloads/file/?id=480720
#tar -xvf mysql-8.0.13-1.el6.x86_64.rpm-bundle.tar
rpm -ivh mysql-community-common-8.0.13-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.13-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-compat-8.0.13-1.el6.x86_64.rpm
rpm -ivh mysql-community-client-8.0.13-1.el6.x86_64.rpm
rpm -ivh mysql-community-server-8.0.13-1.el6.x86_64.rpm
//centos6
#service mysqld start
#service mysqld restart
#service mysqld status//查看状态
#chkconfig mysqld on//设置开机自启
#mysql -V //查看版本
//centos7开启、关闭
[root@tencent-cloud ~]# systemctl start mysqld.service
[root@tencent-cloud ~]# systemctl stop mysqld.service
[root@tencent-cloud ~]# systemctl status mysqld.service
systemctl enable mysqld
错误日志路径,/var/log/mysqld.log
mysql.sock所在路径,/var/lib/mysql/mysql.sock
#tar cvf mysql_data.tar data
#tar cvzf mysql.tar.gz mysql
#netstat -lnp|grep 3306
#chown -R mysql:mysql mysql
#ps -aux|grep mysql
#mysql_secure_installation
//将正确的socket文件位置,软链接到提示错误的socket文件路径位置
#ln -s /var/lib/mysql/mysql.sock /usr/local/webserver/mysql/mysql.sock
#grep 'temporary password' /var/log/mysqld.log
[root@tencent-cloud ~]# mysql_secure_installation
#会依次出现以下问题。
Set root password? [Y/n]
是否设置root用户的密码 (y后【设置登录密码】)
Remove anonymous users? [Y/n]
是否删除匿名用户 (y)
Disallow root login remotely? [Y/n]
是否禁止root远程登录 (n)
Remove test database and access to it? [Y/n]
是否删除test数据库(y)
Reload privilege tables now? [Y/n]
是否重新加载授权信息 (y)
//创建远程登录的用户
# 先进入mysql
mysql -u root -p
# 授权(root用户)远程连接权限(不建议)
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '远程登录密码' WITH GRANT OPTION;
FLUSH PRIVILEGES;
# 使用单独的远程登录用户(推荐)
GRANT ALL PRIVILEGES ON *.* TO '新用户名'@'%' IDENTIFIED BY '远程登录密码' WITH GRANT OPTION;
FLUSH PRIVILEGES;
#mysql -u root -p
#ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';
use mysql;
show tables;
update user set host = '%' where user = 'root';
FLUSH PRIVILEGES;
exit;
ERROR同一ip在短时间内产生太多(超过mysql数据库max_connection_errors的最大值)
终端的数据库连接而导致的阻塞
2、升级
//备份数据库
mysqldump --all-databases -p -u root > /home/mysql.data.bak
1.配置新的yum源。
[root@centosphpyum ~]# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -ivh epel-release-6-8.noarch.rpm
rpm -ivh remi-release-6.rpm
配置源配置文件:
ls -1 /etc/yum.repos.d/epel* /etc/yum.repos.d/remi.repo
编辑[remi]下的enabled选项从0设为1
3.更新库更新完成后,开始升级mysql。
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
4.查看更新库中可用的版本:
yum --enablerepo=remi,remi-test list mysql mysql-server
5.升级mysql。
yum --enablerepo=remi install mysql mysql-server
6.升级成功。
1.下载安装官方yum源
wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
rpm -ivh mysql57-community-release-el7-11.noarch.rpm
2.编辑配置 /etc/yum.repos.d/mysql-community.repo
vim /etc/yum.repos.d/mysql-community.repo
可以看到,文件中列出了mysql的各个版本,其中enabled=1表示选择安装或升级到此版本,
可以看到已经默认选择了5.7版本,其他版本全是enabled=0,注意只能有一个版本设置为选中状态,
否则会直接安装、升级最新版本。
3.升级mysql
yum update mysql-server
确认版本选择正确后,使用yum update mysql-server,yum就会升级到选择的对应版本mysql-server,
并且自动会升级相关包,整个过程基本没有任何多余操作,安装完成后,直接就可以使用了