查看是否已安装mysqlrpm -qa | grep mysql
查看默认数据库mariadb版本rpm -qa|grep -i mariadb
卸载已安装的mariadb(不能直接安装mysql,直接安装只会更新mariadb)rpm -qa|grep mariadb|xargs rpm -e --nodeps
下载mysql安装源wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
安装mysql安装源rpm -ivh mysql-community-release-el7-5.noarch.rpm
安装mysql(如果源没有安装成功则显示没有此包)yum install mysql-server
检查mysql5.6是否已安装rpm -qa | grep mysql
mysql服务的启停systemctl start mysqld.service(启动)
systemctl stop mysqld.service(停止)
systemctl restart mysqld.service(重启)
systemctl enable mysqld.service(添加至开机自启)
mysql默认路径/etc/my.cnf (主配置文件)
/var/lib/mysql (数据库文件)
/var/logs/mysqld.log(日志输出)
mysql基本操作mysql -uroot
CREATE USER 'username'@'host' IDENTIFIED BY 'password';(创建用户)
GRANT privileges ON databasename.tablename TO 'username'@'host' WITH GRANT OPTION;(用户授权)
SET PASSWORD FOR 'username'@'host' = PASSWORD('newpassword');(修改用户密码)
REVOKE privilege ON databasename.tablename FROM 'username'@'host';(撤销用户授权)
DROP USER 'username'@'host';(删除用户)