CentOS 7:
1.检查系统是否已经安装mysql
rpm -qa | grep mysql
2.删除原版
2.1普通模式删除rpm -e mysql-community-devel
rpm -e mysql-community-libs
2.2强力删除rpm -e --nodeps mysql-community-common
2.3检查执行效果rpm -qa | grep mysql
3.客户端安装: yum install mysql
4.服务端安装: yum install mysql-server 可能会失败:
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-server
5.开发包安装: yum install mysql-devel
Ubuntu:
1.删除
apt-get autoremove mysql
2.安装
apt-get install mysql-server
apt-get install mysql-client
配置:
1.安装完成,root登录
第一次,修改密码:mysqladmin -u root password ‘new password‘
2.配置文件目录
/etc/mysql/my.conf (ubuntu)
/etc/my.cnf (CentOS)
2.简单操作默认数据表:
show databases; //查看所有数据库
use mysql; //使用名为mysql的数据库
show columns from user; //查询命令
3.服务配置
服务启动/关闭:service mysql start/stop
Centos7下也可以 systemctl start/stop mysql.service
开机启动/不启动:systemctl enable/disable mysqld.service
检查各项服务状态:systemctl list-unit-files | grep mysql
4.查看监听端口占用情况:
netstat -antp| grep 3306
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 6633/mysqld
netstat -tap | grep mysql
tcp 0 0 localhost:mysql *:* LISTEN 6633/mysqld