CentOS7安装mysql

  1. 卸载默认安装的mariadb
yum search mysql
yum remove mariadb.x86_64
  1. MySQL Community Downloads

Linux7 即 CentOS7

  1. 安装:wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

注:推荐在/tmp目录下进行

  1. 本地安装yum源:yum localinstall mysql
  2. 检测是否已经安装:yum search mysql
  3. 找到对应的软件包,复制名称
  4. 使用yum安装:yum install mysql-community-server.x86_64
  5. 查看是否安装成功:ps -ef | grep mysql
  6. 启动mysql
service mysqld start
service mysqld restart
service mysqld stop
  1. 查找默认登录密码:cat /var/log/mysqld.log | grep password
  2. 登录:mysql -uroot -p密码

注:推荐使用 mysql -uroot-p 回车之后再输入密码。因为使用history命令会看到你明文的密码

  1. 修改密码:SET PASSWORD = PASSWORD(’ xxxx ');
  2. 开通远程连接权限
use mysql;
show tables;
select * from user \G  # \G会格式化显示
select host, user from user \G
update user set host="%" where Host='localhost' and user = "root";
# 更新权限
flush privileges;
# 或者重启服务:service mysqld restart

你可能感兴趣的:(Linux,#,MySQL,mysql,linux,centos)