Install
MySql on CentOS 7
CentOS 7
no longer comes with
Mysql
database, the default database is
MariaDB
(
a branch of
Mysql ).
Before installing
MySQL ,
uninstall the mariadb
that comes with the system
The installation package can be downloaded from my resources
2.1
Query
Mysql
and
Mariadb
# find / -name mysql
Find
files and folders with
mysql name
# rpm -qa|grep
mysql
Find out if MySQL is installed ( case sensitive )
# rpm -qa|grep -i mysql
Find out if
MySQL is installed
(
case insensitive
)
# rpm -qa | grep mariadb
result
mariadb-libs-5.5.44-2.el7.centos.x86_64
2.2
Uninstall
uninstall
mysql
# rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64
卸载
mariadb
# rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64
2.3
安装
# rpm -ivh MySQL-server-5.5.47-1.linux2.6.x86_64.rpm
如果需要安装
Mysql
时出现下面情况,先安装
mysql
的
libaio
依赖
#
rpm -
ivh
libaio-0.3.107-10.el6.x86_64.rpm
然后再安装服务端的
mysql,
如果安装不上
那只能强制安装
—
nodeps
# rpm -ivh MySQL-server-5.5.47-1.linux2.6.x86_64.rpm --nodeps
# rpm -ivh MySQL-client-5.5.47-1.linux2.6.x86_64.rpm –nodeps
2.4
查询服务是否开启
# service mysql status
查看
mysql
服务是否开启
2.5
开启服务
# service mysql start
2.6
开机自动启动
mysql
服务
# chkconfig mysql on
2.6.5
查看所有服务
#
chkconfig –list
2.
7
进入
MySql
# mysql -uroot
第一次进入不需要密码
2.8
改密码
# update mysql.user set password=PASSWORD(123456) where User='root';
密码可以是字符串
将
root
用户的密码改为
root
,这样只能本地登录,远程不能登录
2
.8.5
查询用户所拥有的访问权限信息的命令如下:
mysql >
select host,user,password from
mysql.
user
;
2.9
改所有机子访问
root
权限
# grant all privileges on *.* to 'root'@'%' identified by '123456';
2.10
刷新权限
# flush privileges;
2.11
退出
mysql
# exit
c
reate
database ht;
show databases;
use ht;
create table tutorials_tbl(
tutorial_id INT NOT NULL AUTO_INCREMENT,
tutorial_title VARCHAR(100) NOT NULL,
tutorial_author VARCHAR(40) NOT NULL,
submission_date DATE,
PRIMARY KEY ( tutorial_id )
);
show tables