linux -安装mysql,配置密码,开启远程访问
1.安装
下载yum源的安装包 yum install https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
如果上面的源导致安装失败,可以使用下面的
yum install https://repo.mysql.com/mysql80-community-release-el8.rpm
如果都不符号,
可以访问
https://repo.mysql.com
里面有很多,挑选自己需要的就行
安装 yum install mysql-community-server 启动服务 service mysqld start 查看状态 service mysqld status
2.改密码
查看初始密码【会显示临时的初始密码】 grep 'temporary password' /var/log/mysqld.log 登录【输入临时的初始密码】 mysql -uroot -p 更改密码: 密码必需要数字,大小写字母,特殊符号。修改好后退出。 alter user 'root'@'localhost' identified by '新密码' 退出 exit 关闭mysql服务 service mysqld stop 再次启动 service mysqld start 使用新密码输入 mysql -uroot -p
3.开启远程访问并新建账号
开启远程访问 【root是账号,一般使用root 】,下面三条修改完参数后分别执行 create user 'root'@'%' identified with mysql_native_password by '密码'; grant all privileges on *.* to 'root'@'%' with grant option; flush privileges;
4.云服务器配置
记得开启端口 3306
5.卸载
//yum安装方式下载 1.查看已安装的mysql 命令:rpm -qa | grep -i mysql 2.卸载mysql 命令:
yum remove 《上面指令的包名,记得去掉后缀》
如:yum remove mysql-community-server-5.6.36-2.el7.x86_64 查看mysql的其它依赖:rpm -qa | grep -i mysql //卸载依赖 yum remove mysql-libs yum remove mysql-server yum remove perl-DBD-MySQL yum remove mysql
6.报错处理
如果安装报错出现
The GPG keys listed for the "MySQL 8.0 Community Server" repository are already installed but they are not correct for this package. Check that the correct key URLs are configured for this repository. Failing package is: mysql-community-icu-data-files-8.0.29-1.el7.x86_64 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
那么换一个源重新安装,记得先卸载
本文来自博客园,作者:岑惜,转载请注明原文链接:https://www.cnblogs.com/c2g5201314/p/15775956.html
响应开源精神相互学习,内容良币驱除劣币

浙公网安备 33010602011771号