Linux上安装mysql

1.查看Linux上是否自带mysql或者已经装过mysql

    [[email protected] ~]# rpm -qa | grep -i mysql

        如果没有安装,就不会显示关于mysql的信息,如果有,删除:

        [[email protected] ~]# rpm -e --nodeps 软件包名

2.在/usr/local下建立目录 mysql

        [[email protected] ~]# cd /usr/local

        [[email protected] local]# mkdir mysql

3.在目录mysql下:

        [[email protected] mysql]#  wget http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-5.6.22-1.el6.i686.rpm-bundle.tar

4.解压安装包

        [[email protected] mysql]# tar -xvf  MySQL-5.6.22-1.el6.i686.rpm-bundle.tar

5.查看

        [[email protected] mysql]# ll

CentOs7上安装mysql

 

6.安装serve

    [[email protected] mysql]# rpm -ivh  MySQL-server-5.6.22-1.el6.i686.rpm

    报错

CentOs7上安装mysql

安装依赖:

[[email protected] mysql]#  yum -y install libaio.so.1 libgcc_s.so.1 libstdc++.so.6

重新安装

[[email protected] mysql]# rpm -ivh  MySQL-server-5.6.22-1.el6.i686.rpm

CentOs7上安装mysql----用户root的随机密码存储地方

[[email protected] mysql]# cat /root/.mysql_secret

CentOs7上安装mysql

 

7.安装client

[[email protected] mysql]# rpm -ivh MySQL-client-5.6.22-1.el6.i686.rpm

    报错

CentOs7上安装mysql

    安装依赖:

    [[email protected] mysql]# yum -y install libncurses.so.5 libtinfo.so.5

    重新安装

    [[email protected] mysql]# rpm -ivh MySQL-client-5.6.22-1.el6.i686.rpm

 

8.查看mysql的服务状态

    [[email protected] mysql]# service mysql status

 CentOs7上安装mysql----mysql没有被启动

或者

    [[email protected] mysql]# ps -ef|grep mysql

CentOs7上安装mysql---表示没有启动

9.启动mysql

    [[email protected] mysql]# service mysql start

CentOs7上安装mysql---启动成功,说明安装成功

或者

    [[email protected] mysql]# ps -ef|grep mysql

CentOs7上安装mysql

 

10.使用root用户登录mysql

    [[email protected] mysql]# mysql -u root -p

    entering password:----这里注意,在第一次使用root用户登录时,这里的密码就是那个随机密码

进入mysql:

mysql>show database;

CentOs7上安装mysql

 

11.修改密码

mysql> set password = password('root');

CentOs7上安装mysql---修改成功

退出Mysql

mysql>exit

 

12.重新进入mysql

[[email protected] mysql]#mysql -u root -p

entering password:-----这里输入密码:root

进入mysql:

mysql>show database;

CentOs7上安装mysql

 

13.当Linux打开时,自动启动,不需要手动启动

    [[email protected] mysql]# chkconfig --add mysql ----将mysql加入到系统服务中

    [[email protected] mysql ]# chkconfig mysql on------自动启动

测试(这里已经将Mysql关闭了):

    [[email protected] mysql]# mysql -u root -p

    entering password:----这里输入root,如果直接进入了mysql中,说明其自动启动了

CentOs7上安装mysql---这样就需要手动启动mysql服务

 

14.远程访问Linux上的mysql

    1).点击

        CentOs7上安装mysql

    2).点击新连接

        CentOs7上安装mysql

    3).

        CentOs7上安装mysql

这里点击连接时,可能会报错:

    (1).当前的Linux上的mysql没有开放远程访问的权限,需要:

    mysql> grant all privileges on *.* to 'root' @ '%' identified by 'root';

    刷新:

    mysql> flush privileges;

    (2).再次连接,还是失败,这里可能是Linux上的防火墙没有关闭

    [[email protected] mysql]# systemctl stop firewalld

    [[email protected] mysql]# systemctl disable firewalld ----开机就自动关闭

再点击连接,成功

CentOs7上安装mysql

参考:https://blog.csdn.net/ruipeng250/article/details/79395847

相关文章: