Linux安装mySql详解

前置:
(1)防火墙关闭
    service iptables stop 
    chkconfig iptables off:开机不启动防火墙
(2)关闭selinux

安装Mysql

(1)检查Linux是否自带的有mysql安装包 

           rpm -qa | grep mysql

(2)卸载linux自带mysql包
        rpm -e --nodeps mysql-libs-5.1.66-2.el6_3.x86_64

(3)通过yum安装mysql
        yum install -y mysql-server
        成功的话,可以看到“Complete!”
        默认安装的是5.1.73

(4)启动mysql服务
        service mysqld start
        如果是5.1的版本,mysql的服务名称:mysqld
        版本>5.5 ,mysql的服务名称:mysql

扫描二维码关注公众号,回复: 9348784 查看本文章

(5)设置root用户密码,
            /usr/bin/mysqladmin -u root password '123'

 (6)  验证:
                mysql -u root -p
                    show databases
                    use mysql
                    show tables

(7)让mysql服务,随着系统的启动而启动
        查看:
            chkconfig mysqld --list 


        修改:
            chkconfig mysqld  on


        查看:
            chkconfig mysqld --list 

(8)在mysql配置对应的权限

        a:授权
            grant all privileges on *.* to 'root'@'%' identified by '123' with grant option

     b:mysql新建连接

  c:查询 
            select host,user,password from user;

经验告诉你,只保留一条:

d:刷新权限(必须执行)
            flush privileges

(9)重启mysql服务
        service mysqld restart

发布了88 篇原创文章 · 获赞 383 · 访问量 10万+

猜你喜欢

转载自blog.csdn.net/weixin_42047611/article/details/81393779
今日推荐