赞
踩
用过rpm安装和yum安装,还是觉得yum安装最方便,下面是我的安装过程(在root下运行)
rpm -qa | grep mysql
mysql80-community-release-el8-1.noarch
mysql-community-client-8.0.18-1.el8.x86_64
mysql-community-libs-8.0.18-1.el8.x86_64
mysql-community-server-8.0.18-1.el8.x86_64
mysql-community-common-8.0.18-1.el8.x86_64
rpm -e mysql
// 普通删除rpm -e --nodeps mysql
// 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除sudo rpm -e --nodeps mysql80-community-release-el8-1.noarch
sudo rpm -e --nodeps mysql-community-client-8.0.18-1.el8.x86_64
sudo rpm -e --nodeps mysql-community-libs-8.0.18-1.el8.x86_64
sudo rpm -e --nodeps mysql-community-server-8.0.18-1.el8.x86_64
sudo rpm -e --nodeps mysql-community-common-8.0.18-1.el8.x86_64
rpm -ivh mysql-community-release-el8-1.noarch.rpm
yum update
yum install mysql-server
chown mysql:mysql -R /var/lib/mysql
mysqld --initialize
systemctl start mysqld
systemctl status mysqld
mysqladmin --version
mysqladmin Ver 8.0.18 for Linux on x86_64 (MySQL Community Server - GPL)
如果以上命令执行后未输出任何信息,说明你的Mysql未安装成功。
mysql -u root -p
mysql> use mysql
mysql>update user set password=password(‘123456’) where user=‘root’;
mysql>flush privileges;
mysql>exit
这时就已经设置好新的root用户密码了
vim /etc/my.cnf
skip-grant-tables
mysql>ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘root-password’;
如果出现
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 ‘(‘root-password’) where user=‘root’’ at line 1
只需输入:
mysql> flush privileges;
再次
mysql>ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘root-password’;
就ok了
更改完密码记得
mysql> flush privileges;
使其生效
mysql>exit
退出后记得将/etc/my.cnf中的skip-grant-tables去掉
create user 'user'@'%' identified by 'password'
update user set host='%' where user='root';
grant all privileges on *.* to 'user'@'%';
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root-password';
vim /etc/my.cnf
加入default-authentication-plugin=mysql_native_password
来更改身份验证插件bind-address=0.0.0.0
使mysql可以远程ip连接navicatSHOW VARIABLES LIKE 'validate_password%';
set global validate_password.policy=0;
flush privileges;
systemctl restart mysqld
有问题欢迎评论。
—4.19更新—
在虚拟机上又按这个顺序安装了一个mysql
mysqladmin Ver 8.0.17 for Linux on x86_64 (Source distribution)
发现安装后的配置文件/etc/my.cnf默认为:
#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
是说配置文件放在/etc/my.cnf.d这个dir(目录)了
cd /etc/my.cnf.d && ls
client.cnf mysql-default-authentication-plugin.cnf mysql-server.cnf
挨个查看,发现里面是客户端和服务端以及默认密码识别配置文件。也就是之前的my.cnf的作用,将其拆分成了这三个,可以选择在my.cnf中配置,也可以在这三个文件中分别配置。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。