Linux安装MySQL

1. 先检查系统是否装有mysql

    rpm -qa | grep mysql

2. 下载mysql的repo源

El7内核

    wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

el6内核

    wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm

    报错: -bash: wget: 未找到命令

    安装插件  yum -y install wget

3. 安装mysql-community-release-el7-5.noarch.rpm包

    sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm

4. 安装MySQL

    sudo yum install mysql-server

    per PDI错误 el6安装:

    wget http://rpmfind.net/linux/centos/6.10/os/x86_64/Packages/perl-DBI-1.609-4.el6.x86_64.rpm

5. 重置MySQL密码

    mysql -u root

    报错:

    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

    原因:原因是/var/lib/mysql的访问权限问题。

    chown root /var/lib/mysql/    

    或者是/etc/my.cnf中添加

    [client]

    port=3306

    socket=/var/lib/mysql/mysql.sock

6. 重启MySQL服务

    service mysqld restart

7. 接着登陆设置密码

    mysql -u root

    use mysql;

    update user set password=password('123456') where user='root';

    exit;

    接着继续重启MySQL服务

    service mysqld restart

8. 接着设置Root账户远程连接密码

    mysql -u root -p

    GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root";

    重启服务器 service mysqld restart

9. 使用外网工具连接MySQL

    关闭防火墙

    systemctl stop firewalld.service

你可能感兴趣的:(Linux安装MySQL)