VMware虚拟机装好后,再装个CentOS7系统,以上环境自行百度...
一、Linux下查看mysql是否安装
1、指令ps -ef|grep mysql
[root@localhost 桌面]# ps -ef|grep mysql mysql 2688 1 0 13:31 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr mysql 2857 2688 0 13:31 ? 00:00:01 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock root 4326 4294 0 13:39 pts/0 00:00:00 grep --color=auto mysql/
2、rpm -qa | grep mysql
[root@localhost 桌面]# rpm -qa | grep mysql mysql-community-libs-5.6.36-2.el7.x86_64 mysql-community-release-el7-5.noarch mysql-community-server-5.6.36-2.el7.x86_64 mysql-community-client-5.6.36-2.el7.x86_64 mysql-community-devel-5.6.36-2.el7.x86_64 mysql-community-common-5.6.36-2.el7.x86_64
3、mysql的守护进程是mysqld
如果已经安装:
[root@localhost 桌面]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service
如果没有安装:
[root@localhost 桌面]# service mysqld start
mysqld:未被识别的服务
二、如果没有安装过mysql
centos7不支持mysql,内部集成了mariadb,而安装mysql的话会和mariadb文件冲突,所以需要先卸载mariadb,以下为卸载mariadb,安装mysql的步骤
#列出所有被安装的rpm package rpm -qa | grep mariadb #卸载 rpm -e mariadb-libs-5.5.37-1.el7_0.x86_64
1、下载mysql的repo源 ,下载地址 http://download.csdn.net/detail/xuxiaoyu__/9890496,把这个安装文件拖到linux可视化界面上,
2、安装rpm包,执行安装命令:
[root@localhost 桌面]# rpm -ivh '/home/xuxiaoyu/桌面/mysql-community-release-el7-5.noarch.rpm' (回车)
准备中... ################################# [100%]
软件包 mysql-community-release-el7-5.noarch 已经安装
3、安装myslq:yum install mysql-server(如果不成功,就操作步骤4)
4、使用yum安装mysql数据库(在操作之前我先执行了这个命令,因为刚开始装mysql时,各种错,就按着网上说的去试了 yum install -y perl perl-devela)
输入:yum -y install mysql-server mysql mysql-devel ,命令将:mysql-server、mysql、mysql-devel都安装好,当结果显示为“Complete!”即安装完毕。
注:安装mysql只是安装了数据库,只有安装mysql-server才相当于安装了客户端。
三、安装成功后对mysql的相关操作
启动mysql:systemctl start mysqld.service
结束:systemctl stop mysqld.service
重启:systemctl restart mysqld.service
连接mysql,进入mysql dos,一开始安装是不需要密码的,回车一下就行(输入exit,回车,退出mysql dos),出现以下页面,说明mysql安装成功,完全可以正常使用!
(参考:http://www.360doc.com/content/16/0617/21/8357485_568631202.shtml)
[root@localhost 桌面]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 4 Server version: 5.6.36 MySQL Community Server (GPL) Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. mysql>
四、其他:
1、杀掉yum进程:rm -f /var/run/yum.pid
2、ctrl+alt+F1/F2 虚拟机可视化界面和dos命令相互切换
3、虚拟机锁屏时,直接输入密码即可解锁
安装jdk:http://www.linuxidc.com/Linux/2016-09/134941.htm