赞
踩
docker run -p 3306:3306 --name mysql57 -v E:\\mysql\\conf:/etc/mysql/conf.d -v E:\\mysql\\data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=root -d mysql:5.7 --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci
my.cnf
[mysqld] innodb_data_file_path=ibdata1:5M;ibdata2:5M:autoextend bind-address = * port = 3306 user = mysql datadir = /var/lib/mysql socket = /var/run/mysqld/mysqld.sock pid_file = /var/run/mysql.pid symbolic-links = 0 default-storage-engine = InnoDB max_allowed_packet = 512M max_connections = 2048 open_files_limit = 65535 character-set-client-handshake = FALSE character-set-server = utf8mb4 collation-server = utf8mb4_general_ci init_connect = 'SET NAMES utf8mb4' key_buffer_size = 64M server_id = 59
华为云镜像MySQL5.7
下载想要的版本,按照官网安装
安装
sudo yum install mysql-community-{server,client,common,libs}-*
sudo yum install mysql-community-{client,common,libs}-* mysql-5.*
# centos
sudo service mysqld start
# 其它
sudo service mysql start
# 查看root用户临时密码
sudo grep 'temporary password' /var/log/mysqld.log
sudo grep 'temporary password' /var/log/mysql/mysqld.log
# 进入到MySQL中
mysql -uroot -p
# 更换root密码,这里注意,密码需要非常复杂,否组修改报错
ALTER USER 'root'@'localhost' IDENTIFIED BY '<MyNewPass4!>';
use mysql;
update user set host = '%' where user = 'root';
select host, user from user;
# 使修改生效
flush privileges;
GRANT ALL PRIVILEGES ON *.* TO '<myuser>'@'%' IDENTIFIED BY '<rootpassword>' WITH GRANT OPTION;
SHOW VARIABLES LIKE 'validate_password%';
# 安装和卸载密码验证
INSTALL PLUGIN validate_password SONAME 'validate_password.so';
uninstall plugin validate_password;
# 设置密码验证
SET GLOBAL validate_password_policy=LOW;
SET GLOBAL validate_password_length = 4;
SET GLOBAL validate_password_policy = 0;
SET GLOBAL validate_password_mixed_case_count = 0;
SET GLOBAL validate_password_number_count = 0;
SET GLOBAL validate_password_special_char_count = 0;
SET GLOBAL validate_password_check_user_name = 0;
FLUSH PRIVILEGES;
原因就是找不到mysql-config,需要安装mysql-devel解决,但是博主在安装时,报错mariadb报错,查看版本,mariadb5.5,MySQL5.7,猜测可能是这个原因导致,卸载mariadb后,成功运行。装的是官网的安装包mysql-devel
# 查看yum安装列表
yum list installed | grep mariadb
# 卸载
yum erase <name>
要知道一些原理,不要直接按照网上的博文操作,尤其国内的
yum install mysql-devel
yum install mariadb-dev
# 查看mysql安装了哪些东西,卸载 rpm -qa |grep -i mysql yum remove <name> # 直接全部卸载 rpm -qa |grep -i mysql|xargs yum remove -y # 查找文件 find / -name mysql # 删除 rm -rf <name> # 删除/etc/my.cnf rm -rf /etc/my.cnf # 删除/var/log/mysqld.log(如果不删除这个文件,会导致新安装的mysql无法生存新密码,导致无法登陆) rm -rf /var/log/mysqld.log # 注意log的位置可能不同 # 删除mariadb-libs,再安装包 yum remove mariadb-libs
[mysqld]
log-bin=mysql-bin
server-id=1234
参考链接:
解决MySQL不允许(其它IP)从远程访问的方法
Your password does not satisfy the current policy requirements
官网关于密码验证
Centos7 完全卸载mysql
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。