linux安装mysql

Linux服务器安装Mysql的步骤

Linux服务器安装Mysql的步骤

 

1.检查软件是否已经安装

 rpm -qa|grep -i mysql

 

2.强制卸载软件

 rpm -e --nodeps MySQL-server-5.0.22-0

 

3.安装Server端

 rpm -ivh MySQL-server-5.0.22-0.i386.rpm

 

安装MySQL服务端的时候报错,报错信息如下:

 [root@iZ23k6iktncZ ~]# rpm -ivh MySQL-server-5.0.22-0.i386.rpm

error: Failed dependencies:

        ld-linux.so.2 is needed by MySQL-server-5.0.22-0.i386

        libc.so.6 is needed by MySQL-server-5.0.22-0.i386

        libc.so.6(GLIBC_2.0) is needed by MySQL-server-5.0.22-0.i386

        libc.so.6(GLIBC_2.1) is needed by MySQL-server-5.0.22-0.i386

        libc.so.6(GLIBC_2.1.2) is needed by MySQL-server-5.0.22-0.i386

        libc.so.6(GLIBC_2.1.3) is needed by MySQL-server-5.0.22-0.i386

        libc.so.6(GLIBC_2.2) is needed by MySQL-server-5.0.22-0.i386

        libcrypt.so.1 is needed by MySQL-server-5.0.22-0.i386

        libm.so.6 is needed by MySQL-server-5.0.22-0.i386

        libnsl.so.1 is needed by MySQL-server-5.0.22-0.i386

        libnss_dns.so.2 is needed by MySQL-server-5.0.22-0.i386

        libnss_files.so.2 is needed by MySQL-server-5.0.22-0.i386

        libpthread.so.0 is needed by MySQL-server-5.0.22-0.i386

        libpthread.so.0(GLIBC_2.0) is needed by MySQL-server-5.0.22-0.i386

        libpthread.so.0(GLIBC_2.1) is needed by MySQL-server-5.0.22-0.i386

        libpthread.so.0(GLIBC_2.2) is needed by MySQL-server-5.0.22-0.i386

        libresolv.so.2 is needed by MySQL-server-5.0.22-0.i386

 

解决方法(执行下面一行命令):

 yum install -y gcc gcc-c++ gcc4-c++ pam-devel

 

 

4.如果你安装的机器此时可以连接到互联网,可以跳过第3步使用yum命令来简化安装过程:

        yum install mysql-server mysql-devel mysql

        yum将自动从centos的镜像站点查找你指明的软件的最新二进制包,并检查软件包依赖关系,安装软件的同时自动安装其依赖的软件包。

 

5.启动mysqld服务

 service mysqld start

 

6.设置mysql帐号

以root帐号连接到mysql服务器:

           mysql -u root 

改变当前数据库为mysql:

           use mysql

设置从本地主机登录的root帐号密码:

           set password for root@localhost=password('your password');

           或:

           update user set password=password('your password') where user='root' and host='localhost';

删除匿名帐号: 

           delete from user where user='' ;

删除密码为空的帐号:

           delete from user where password='';

删除允许非localhost主机登录的帐号:

           delete from user where host<>'localhost' ;

执行下面的命令使更改生效:

           flush privileges ; 

执行下面的命令退出mysql命令行:

           quit 或:exit

 

7.查看mysql的安装路径

 whereis mysql

 

8.查看mysql版本号

 mysql -V  或者  mysql --version

 

9.设置开机启动

 

设置开机自启动的方法有很多,例如使用chkconfig命令,另外也可以在/etc/rc.local文件中加上如下MySQL的启动命令,例如:

 

/etc/rc.d/init.d/mysql start

 

设置完成后重启系统,使用natstat –nat命令可看到MySQL的3306端口:

 

[root@iZ23k6iktncZ init.d]# netstat -nat

Active Internet connections (servers and established)

Proto Recv-Q Send-Q     Local Address         Foreign Address             State      

tcp        0      0                  0.0.0.0:8009                0.0.0.0:*                   LISTEN      

tcp        0      0                  0.0.0.0:3306                0.0.0.0:*                   LISTEN      

tcp        0      0                  0.0.0.0:3690                0.0.0.0:*                   LISTEN

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值